[llvm-branch-commits] [flang] [llvm] [Flang] Move runtime library files to FortranRuntime. NFC (PR #110298)

Michael Kruse via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Fri Sep 27 09:43:18 PDT 2024


https://github.com/Meinersbur created https://github.com/llvm/llvm-project/pull/110298

Mostly mechanical changes in preparation of extracting the FortranRuntime "subproject" in #110217. This PR intends to only move pre-existing files to the new folder structure, with no behavioral change.

`Common` and `Testing` are the directories shared by FortranRuntime and Flang. `Runtime` and `module` are going to be used by FortranRuntime only. Files in `Common` that are used only by Flang are moved into `Support`.

Some cosmetic changes and files paths were necessary:
 * Relative paths to the new path for the source files and `add_subdirectory`.
 * Add the new location's include directory to `include_directories`
 * The unittest/Evaluate directory has unitests for FortranRuntime and Flang. A new `CMakeLists.txt` was introduced for the FortranRuntime tests.
 * Change the of the `#include` paths relative to the include directive
 * clang-format on the `#include` directives
 * Since the paths is part if the copyright header and include guards, a script was used to canonicalize those
 * `test/Runtime` is has single non-unittest file that remain in the `flang` top-level directory. There is no easy way for lit to find the file in a sibling directory.



>From 2216bfe4a07625d894accf5730a313a65d30a982 Mon Sep 17 00:00:00 2001
From: Michael Kruse <llvm-project at meinersbur.de>
Date: Fri, 27 Sep 2024 17:20:13 +0200
Subject: [PATCH] Move files to FortranRuntime

---
 FortranRuntime/.clang-format                  | 21 +++++++++
 .../cmake/config.h.cmake.in                   |  0
 .../include/flang/Common/Fortran-consts.h     |  0
 .../flang/Common}/ISO_Fortran_binding.h       | 13 +++---
 .../Common}/ISO_Fortran_binding_wrapper.h     | 13 +++---
 .../include/flang/Common/api-attrs.h          | 11 +++--
 .../flang/Common}/binary-floating-point.h     |  8 ++--
 .../flang/Common/bit-population-count.h       |  2 +-
 .../include/flang/Common/constexpr-bitset.h   |  2 +-
 .../include/flang/Common}/decimal.h           | 11 +++--
 .../include/flang/Common/enum-class.h         |  2 +-
 .../include/flang/Common/enum-set.h           |  2 +-
 .../include/flang/Common/fast-int-set.h       |  4 +-
 .../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 +-
 .../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        |  8 ++--
 .../include/flang/Runtime/array-constructor.h |  6 +--
 .../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        |  4 +-
 .../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            |  2 +-
 .../include/flang/Runtime/iostat.h            |  2 +-
 .../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/memory.h            |  2 +-
 .../include/flang/Runtime/misc-intrinsic.h    |  2 +-
 .../include/flang/Runtime/numeric.h           |  2 +-
 .../include/flang/Runtime/pointer.h           |  2 +-
 .../include/flang/Runtime/ragged.h            |  4 +-
 .../include/flang/Runtime/random.h            |  5 +++
 .../include/flang/Runtime/reduce.h            |  2 +-
 .../include/flang/Runtime/reduction.h         |  2 +-
 .../include/flang/Runtime/stop.h              |  2 +-
 .../include/flang/Runtime/support.h           |  4 +-
 .../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       | 14 ++++--
 .../include/flang/Testing}/testing.h          | 14 ++++--
 .../lib/Common}/big-radix-floating-point.h    | 12 +++---
 .../lib/Common}/binary-to-decimal.cpp         |  4 +-
 .../lib/Common}/decimal-to-binary.cpp         |  6 +--
 .../lib/Runtime}/CMakeLists.txt               |  5 ++-
 .../lib/Runtime}/CUDA/CMakeLists.txt          |  0
 .../lib/Runtime}/CUDA/allocator.cpp           |  4 +-
 .../lib/Runtime}/CUDA/descriptor.cpp          |  2 +-
 .../lib/Runtime}/Float128Math/CMakeLists.txt  |  0
 .../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  |  8 ++--
 .../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     |  4 +-
 .../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      |  6 +--
 .../lib/Runtime}/ISO_Fortran_util.h           |  8 ++--
 .../lib/Runtime}/allocatable.cpp              |  8 ++--
 .../lib/Runtime}/allocator-registry.cpp       |  2 +-
 .../lib/Runtime}/array-constructor.cpp        |  8 ++--
 .../lib/Runtime}/assign-impl.h                |  4 +-
 .../lib/Runtime}/assign.cpp                   |  4 +-
 .../lib/Runtime}/buffer.cpp                   |  2 +-
 .../lib/Runtime}/buffer.h                     |  6 +--
 .../lib/Runtime}/character.cpp                |  6 +--
 .../lib/Runtime}/command.cpp                  |  4 +-
 .../lib/Runtime}/complex-powi.cpp             | 15 +++----
 .../lib/Runtime}/complex-reduction.c          |  5 +--
 .../lib/Runtime}/complex-reduction.h          |  7 ++-
 .../lib/Runtime}/connection.cpp               |  2 +-
 .../lib/Runtime}/connection.h                 | 10 ++---
 .../lib/Runtime}/copy.cpp                     |  6 +--
 .../lib/Runtime}/copy.h                       |  4 +-
 .../lib/Runtime}/derived-api.cpp              |  5 +--
 .../lib/Runtime}/derived.cpp                  |  4 +-
 .../lib/Runtime}/derived.h                    |  4 +-
 .../lib/Runtime}/descriptor-io.cpp            |  2 +-
 .../lib/Runtime}/descriptor-io.h              | 12 +++---
 .../lib/Runtime}/descriptor.cpp               |  4 +-
 .../lib/Runtime}/dot-product.cpp              |  8 ++--
 .../lib/Runtime}/edit-input.cpp               |  6 +--
 .../lib/Runtime}/edit-input.h                 |  6 +--
 .../lib/Runtime}/edit-output.cpp              |  4 +-
 .../lib/Runtime}/edit-output.h                |  8 ++--
 .../lib/Runtime}/emit-encoded.h               |  4 +-
 .../lib/Runtime}/environment-default-list.h   |  5 +--
 .../lib/Runtime}/environment.cpp              |  2 +-
 .../lib/Runtime}/environment.h                |  6 +--
 .../lib/Runtime}/exceptions.cpp               |  2 +-
 .../lib/Runtime}/execute.cpp                  |  4 +-
 .../lib/Runtime}/extensions.cpp               |  6 +--
 .../lib/Runtime}/external-unit.cpp            |  2 +-
 .../lib/Runtime}/extrema.cpp                  |  4 +-
 .../lib/Runtime}/file.cpp                     |  4 +-
 .../lib/Runtime}/file.h                       |  6 +--
 .../lib/Runtime}/findloc.cpp                  |  4 +-
 .../lib/Runtime}/format-implementation.h      | 10 ++---
 .../lib/Runtime}/format.cpp                   |  2 +-
 .../lib/Runtime}/format.h                     |  8 ++--
 .../lib/Runtime}/inquiry.cpp                  |  4 +-
 .../lib/Runtime}/internal-unit.cpp            |  4 +-
 .../lib/Runtime}/internal-unit.h              |  8 ++--
 .../lib/Runtime}/io-api-common.h              | 14 +++---
 .../lib/Runtime}/io-api-minimal.cpp           |  4 +-
 .../lib/Runtime}/io-api.cpp                   |  8 ++--
 .../lib/Runtime}/io-error.cpp                 |  4 +-
 .../lib/Runtime}/io-error.h                   |  6 +--
 .../lib/Runtime}/io-stmt.cpp                  |  4 +-
 .../lib/Runtime}/io-stmt.h                    | 10 ++---
 .../lib/Runtime}/iostat.cpp                   |  2 +-
 .../lib/Runtime}/iso_fortran_env_impl.f90     |  2 +-
 .../lib/Runtime}/lock.h                       |  4 +-
 .../lib/Runtime}/main.cpp                     |  2 +-
 .../lib/Runtime}/matmul-transpose.cpp         |  6 +--
 .../lib/Runtime}/matmul.cpp                   |  6 +--
 .../lib/Runtime}/memory.cpp                   |  4 +-
 .../lib/Runtime}/misc-intrinsic.cpp           |  6 +--
 .../lib/Runtime}/namelist.cpp                 |  4 +-
 .../lib/Runtime}/namelist.h                   |  6 +--
 .../lib/Runtime}/non-tbp-dio.cpp              |  2 +-
 .../lib/Runtime}/non-tbp-dio.h                |  4 +-
 .../lib/Runtime}/numeric-templates.h          |  8 ++--
 .../lib/Runtime}/numeric.cpp                  |  4 +-
 .../lib/Runtime}/pointer.cpp                  |  2 +-
 .../lib/Runtime}/product.cpp                  |  4 +-
 .../lib/Runtime}/pseudo-unit.cpp              |  2 +-
 .../lib/Runtime}/ragged.cpp                   |  2 +-
 .../lib/Runtime}/random-templates.h           |  8 ++--
 .../lib/Runtime}/random.cpp                   |  8 ++--
 .../lib/Runtime}/reduce.cpp                   |  4 +-
 .../lib/Runtime}/reduction-templates.h        |  8 ++--
 .../lib/Runtime}/reduction.cpp                |  4 +-
 .../lib/Runtime}/stack.h                      | 10 ++---
 .../lib/Runtime}/stat.cpp                     |  4 +-
 .../lib/Runtime}/stat.h                       |  6 +--
 .../lib/Runtime}/stop.cpp                     |  2 +-
 .../lib/Runtime}/sum.cpp                      |  4 +-
 .../lib/Runtime}/support.cpp                  |  4 +-
 .../lib/Runtime}/temporary-stack.cpp          |  6 +--
 .../lib/Runtime}/terminator.cpp               |  2 +-
 .../lib/Runtime}/terminator.h                 |  4 +-
 .../lib/Runtime}/time-intrinsic.cpp           |  6 +--
 .../lib/Runtime}/tools.cpp                    |  2 +-
 .../lib/Runtime}/tools.h                      |  8 ++--
 .../lib/Runtime}/transformational.cpp         |  6 +--
 .../lib/Runtime}/type-code.cpp                |  3 +-
 .../lib/Runtime}/type-info.cpp                |  2 +-
 .../lib/Runtime}/type-info.h                  |  6 +--
 .../lib/Runtime}/unit-map.cpp                 |  2 +-
 .../lib/Runtime}/unit-map.h                   |  8 ++--
 .../lib/Runtime}/unit.cpp                     |  2 +-
 .../lib/Runtime}/unit.h                       | 14 +++---
 .../lib/Runtime}/utf.cpp                      |  2 +-
 .../lib/Runtime}/utf.h                        |  4 +-
 .../lib/Testing}/fp-testing.cpp               |  4 +-
 .../lib/Testing}/testing.cpp                  | 10 ++++-
 .../module/.clang-format                      |  0
 .../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 ++++++++++++++-----
 .../unittests/Common/CMakeLists.txt           |  0
 .../unittests/Common/FastIntSetTest.cpp       |  4 +-
 .../unittests/Decimal/CMakeLists.txt          |  0
 .../unittests/Decimal/quick-sanity-test.cpp   | 10 ++++-
 .../unittests/Decimal/thorough-test.cpp       | 10 ++++-
 .../unittests/Evaluate/CMakeLists.txt         |  6 +++
 .../Evaluate/ISO-Fortran-binding.cpp          | 12 +++++-
 .../unittests/Evaluate/reshape.cpp            | 10 ++++-
 .../unittests/Runtime/AccessTest.cpp          |  4 +-
 .../unittests/Runtime/Allocatable.cpp         |  4 +-
 .../unittests/Runtime/ArrayConstructor.cpp    |  6 +--
 .../unittests/Runtime/BufferTest.cpp          |  4 +-
 .../unittests/Runtime/CMakeLists.txt          |  0
 .../unittests/Runtime/CUDA/AllocatorCUF.cpp   |  6 +--
 .../unittests/Runtime/CUDA/CMakeLists.txt     |  0
 .../unittests/Runtime/CharacterTest.cpp       |  4 +-
 .../unittests/Runtime/CommandTest.cpp         |  6 +--
 .../unittests/Runtime/Complex.cpp             |  0
 .../unittests/Runtime/CrashHandlerFixture.cpp |  4 +-
 .../unittests/Runtime/CrashHandlerFixture.h   |  8 ++--
 .../unittests/Runtime/Derived.cpp             |  6 +--
 .../unittests/Runtime/ExternalIOTest.cpp      |  4 +-
 .../unittests/Runtime/Format.cpp              |  8 ++--
 .../unittests/Runtime/Inquiry.cpp             |  6 +--
 .../unittests/Runtime/ListInputTest.cpp       |  4 +-
 .../unittests/Runtime/LogicalFormatTest.cpp   |  2 +-
 .../unittests/Runtime/Matmul.cpp              |  6 +--
 .../unittests/Runtime/MatmulTranspose.cpp     |  6 +--
 .../unittests/Runtime/MiscIntrinsic.cpp       |  6 +--
 .../unittests/Runtime/Namelist.cpp            |  6 +--
 .../unittests/Runtime/Numeric.cpp             |  4 +-
 .../unittests/Runtime/NumericalFormatTest.cpp |  2 +-
 .../unittests/Runtime/Pointer.cpp             |  6 +--
 .../unittests/Runtime/Ragged.cpp              |  2 +-
 .../unittests/Runtime/Random.cpp              |  4 +-
 .../unittests/Runtime/Reduction.cpp           |  6 +--
 .../unittests/Runtime/RuntimeCrashTest.cpp    |  6 +--
 .../unittests/Runtime/Stop.cpp                |  4 +-
 .../unittests/Runtime/Support.cpp             |  6 +--
 .../unittests/Runtime/TemporaryStack.cpp      |  8 ++--
 .../unittests/Runtime/Time.cpp                |  4 +-
 .../unittests/Runtime/Transformational.cpp    |  6 +--
 .../unittests/Runtime/tools.h                 |  6 +--
 flang/CMakeLists.txt                          |  7 +--
 flang/include/flang/Evaluate/call.h           |  6 +--
 .../include/flang/Evaluate/characteristics.h  |  6 +--
 flang/include/flang/Evaluate/common.h         |  8 ++--
 flang/include/flang/Evaluate/constant.h       |  4 +-
 flang/include/flang/Evaluate/expression.h     |  6 +--
 flang/include/flang/Evaluate/formatting.h     |  2 +-
 flang/include/flang/Evaluate/intrinsics.h     |  2 +-
 flang/include/flang/Evaluate/shape.h          |  2 +-
 flang/include/flang/Evaluate/target.h         |  2 +-
 flang/include/flang/Evaluate/tools.h          |  4 +-
 flang/include/flang/Evaluate/traverse.h       |  2 +-
 flang/include/flang/Evaluate/type.h           |  6 +--
 flang/include/flang/Evaluate/variable.h       |  4 +-
 .../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       |  4 +-
 .../{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/Common/CMakeLists.txt               | 10 ++---
 flang/lib/Decimal/CMakeLists.txt              | 23 +++++-----
 flang/lib/Evaluate/call.cpp                   |  2 +-
 flang/lib/Evaluate/characteristics.cpp        |  2 +-
 flang/lib/Evaluate/common.cpp                 |  3 ++
 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 |  2 +-
 flang/lib/Optimizer/CodeGen/TypeConverter.cpp |  2 +-
 flang/lib/Optimizer/Dialect/FIRType.cpp       |  2 +-
 .../lib/Optimizer/Transforms/AddDebugInfo.cpp |  2 +-
 .../Transforms/AssumedRankOpConversion.cpp    |  2 +-
 .../Optimizer/Transforms/CufOpConversion.cpp  |  2 +-
 .../Transforms/ExternalNameConversion.cpp     |  2 +-
 .../Optimizer/Transforms/LoopVersioning.cpp   |  2 +-
 .../Transforms/SimplifyIntrinsics.cpp         |  2 +-
 .../lib/Optimizer/Transforms/StackReclaim.cpp |  2 +-
 flang/lib/Optimizer/Transforms/VScaleAttr.cpp |  2 +-
 flang/lib/Parser/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 +-
 .../{Common => Support}/Fortran-features.cpp  |  6 +--
 flang/lib/{Common => Support}/Fortran.cpp     |  6 +--
 flang/lib/{Common => Support}/Version.cpp     |  4 +-
 .../lib/{Common => Support}/default-kinds.cpp |  4 +-
 flang/lib/{Common => Support}/idioms.cpp      |  2 +-
 flang/test/lit.cfg.py                         |  2 +-
 flang/tools/bbc/bbc.cpp                       |  8 ++--
 flang/tools/f18-parse-demo/f18-parse-demo.cpp |  4 +-
 flang/tools/f18/CMakeLists.txt                |  6 ++-
 flang/unittests/CMakeLists.txt                |  6 +--
 flang/unittests/Evaluate/CMakeLists.txt       | 20 ++-------
 .../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 +-
 419 files changed, 873 insertions(+), 777 deletions(-)
 create mode 100644 FortranRuntime/.clang-format
 rename flang/runtime/config.h.cmake => FortranRuntime/cmake/config.h.cmake.in (100%)
 rename {flang => FortranRuntime}/include/flang/Common/Fortran-consts.h (100%)
 rename {flang/include/flang => FortranRuntime/include/flang/Common}/ISO_Fortran_binding.h (95%)
 rename {flang/include/flang => FortranRuntime/include/flang/Common}/ISO_Fortran_binding_wrapper.h (73%)
 rename {flang => FortranRuntime}/include/flang/Common/api-attrs.h (97%)
 rename {flang/include/flang/Decimal => FortranRuntime/include/flang/Common}/binary-floating-point.h (96%)
 rename {flang => FortranRuntime}/include/flang/Common/bit-population-count.h (98%)
 rename {flang => FortranRuntime}/include/flang/Common/constexpr-bitset.h (98%)
 rename {flang/include/flang/Decimal => FortranRuntime/include/flang/Common}/decimal.h (95%)
 rename {flang => FortranRuntime}/include/flang/Common/enum-class.h (98%)
 rename {flang => FortranRuntime}/include/flang/Common/enum-set.h (99%)
 rename {flang => FortranRuntime}/include/flang/Common/fast-int-set.h (97%)
 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 (99%)
 rename {flang => FortranRuntime}/include/flang/Common/leading-zero-bit-count.h (98%)
 rename {flang => FortranRuntime}/include/flang/Common/optional.h (98%)
 rename {flang => FortranRuntime}/include/flang/Common/real.h (99%)
 rename {flang => FortranRuntime}/include/flang/Common/reference-wrapper.h (96%)
 rename {flang => FortranRuntime}/include/flang/Common/restorer.h (97%)
 rename {flang => FortranRuntime}/include/flang/Common/target-rounding.h (100%)
 rename {flang => FortranRuntime}/include/flang/Common/uint128.h (99%)
 rename {flang => FortranRuntime}/include/flang/Common/variant.h (89%)
 rename {flang => FortranRuntime}/include/flang/Common/visit.h (98%)
 rename {flang => FortranRuntime}/include/flang/Common/windows-include.h (93%)
 rename {flang => FortranRuntime}/include/flang/Runtime/CUDA/allocator.h (96%)
 rename {flang => FortranRuntime}/include/flang/Runtime/CUDA/descriptor.h (95%)
 rename {flang => FortranRuntime}/include/flang/Runtime/allocatable.h (99%)
 rename {flang => FortranRuntime}/include/flang/Runtime/allocator-registry.h (89%)
 rename {flang => FortranRuntime}/include/flang/Runtime/array-constructor.h (97%)
 rename {flang => FortranRuntime}/include/flang/Runtime/assign.h (98%)
 rename {flang => FortranRuntime}/include/flang/Runtime/c-or-cpp.h (95%)
 rename {flang => FortranRuntime}/include/flang/Runtime/character.h (99%)
 rename {flang => FortranRuntime}/include/flang/Runtime/command.h (98%)
 rename {flang => FortranRuntime}/include/flang/Runtime/cpp-type.h (98%)
 rename {flang => FortranRuntime}/include/flang/Runtime/derived-api.h (98%)
 rename {flang => FortranRuntime}/include/flang/Runtime/descriptor.h (99%)
 rename {flang => FortranRuntime}/include/flang/Runtime/entry-names.h (89%)
 rename {flang => FortranRuntime}/include/flang/Runtime/exceptions.h (86%)
 rename {flang => FortranRuntime}/include/flang/Runtime/execute.h (89%)
 rename {flang => FortranRuntime}/include/flang/Runtime/extensions.h (97%)
 rename {flang => FortranRuntime}/include/flang/Runtime/freestanding-tools.h (99%)
 rename {flang => FortranRuntime}/include/flang/Runtime/inquiry.h (91%)
 rename {flang => FortranRuntime}/include/flang/Runtime/io-api.h (99%)
 rename {flang => FortranRuntime}/include/flang/Runtime/iostat.h (98%)
 rename {flang => FortranRuntime}/include/flang/Runtime/magic-numbers.h (98%)
 rename {flang => FortranRuntime}/include/flang/Runtime/main.h (95%)
 rename {flang => FortranRuntime}/include/flang/Runtime/matmul-instances.inc (100%)
 rename {flang => FortranRuntime}/include/flang/Runtime/matmul-transpose.h (97%)
 rename {flang => FortranRuntime}/include/flang/Runtime/matmul.h (97%)
 rename {flang => FortranRuntime}/include/flang/Runtime/memory.h (99%)
 rename {flang => FortranRuntime}/include/flang/Runtime/misc-intrinsic.h (95%)
 rename {flang => FortranRuntime}/include/flang/Runtime/numeric.h (99%)
 rename {flang => FortranRuntime}/include/flang/Runtime/pointer.h (99%)
 rename {flang => FortranRuntime}/include/flang/Runtime/ragged.h (96%)
 rename {flang => FortranRuntime}/include/flang/Runtime/random.h (93%)
 rename {flang => FortranRuntime}/include/flang/Runtime/reduce.h (99%)
 rename {flang => FortranRuntime}/include/flang/Runtime/reduction.h (99%)
 rename {flang => FortranRuntime}/include/flang/Runtime/stop.h (97%)
 rename {flang => FortranRuntime}/include/flang/Runtime/support.h (94%)
 rename {flang => FortranRuntime}/include/flang/Runtime/temporary-stack.h (98%)
 rename {flang => FortranRuntime}/include/flang/Runtime/time-intrinsic.h (97%)
 rename {flang => FortranRuntime}/include/flang/Runtime/transformational.h (99%)
 rename {flang => FortranRuntime}/include/flang/Runtime/type-code.h (96%)
 rename {flang/unittests/Evaluate => FortranRuntime/include/flang/Testing}/fp-testing.h (54%)
 rename {flang/unittests/Evaluate => FortranRuntime/include/flang/Testing}/testing.h (74%)
 rename {flang/lib/Decimal => FortranRuntime/lib/Common}/big-radix-floating-point.h (97%)
 rename {flang/lib/Decimal => FortranRuntime/lib/Common}/binary-to-decimal.cpp (99%)
 rename {flang/lib/Decimal => FortranRuntime/lib/Common}/decimal-to-binary.cpp (99%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/CMakeLists.txt (98%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/CUDA/CMakeLists.txt (100%)
 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 (100%)
 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 (98%)
 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 (92%)
 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 (95%)
 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 (89%)
 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 (98%)
 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 (96%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/copy.cpp (99%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/copy.h (89%)
 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 (92%)
 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 (93%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/edit-output.cpp (99%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/edit-output.h (97%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/emit-encoded.h (97%)
 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 (93%)
 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 (97%)
 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 (90%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/io-api-common.h (94%)
 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 (96%)
 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 (96%)
 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 (94%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/non-tbp-dio.cpp (93%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/non-tbp-dio.h (95%)
 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 (96%)
 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 (95%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/stat.cpp (97%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/stat.h (93%)
 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 (97%)
 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 (96%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/unit.cpp (99%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/unit.h (98%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/utf.cpp (98%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/utf.h (96%)
 rename {flang/unittests/Evaluate => FortranRuntime/lib/Testing}/fp-testing.cpp (98%)
 rename {flang/unittests/Evaluate => FortranRuntime/lib/Testing}/testing.cpp (88%)
 rename {flang => FortranRuntime}/module/.clang-format (100%)
 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%)
 rename {flang => FortranRuntime}/unittests/Common/CMakeLists.txt (100%)
 rename {flang => FortranRuntime}/unittests/Common/FastIntSetTest.cpp (97%)
 rename {flang => FortranRuntime}/unittests/Decimal/CMakeLists.txt (100%)
 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 (100%)
 rename {flang => FortranRuntime}/unittests/Runtime/CUDA/AllocatorCUF.cpp (95%)
 rename {flang => FortranRuntime}/unittests/Runtime/CUDA/CMakeLists.txt (100%)
 rename {flang => FortranRuntime}/unittests/Runtime/CharacterTest.cpp (99%)
 rename {flang => FortranRuntime}/unittests/Runtime/CommandTest.cpp (99%)
 rename {flang => FortranRuntime}/unittests/Runtime/Complex.cpp (100%)
 rename {flang => FortranRuntime}/unittests/Runtime/CrashHandlerFixture.cpp (92%)
 rename {flang => FortranRuntime}/unittests/Runtime/CrashHandlerFixture.h (70%)
 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 (93%)
 rename flang/include/flang/{Common => Support}/Fortran-features.h (98%)
 rename flang/include/flang/{Common => Support}/Fortran.h (98%)
 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%)
 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%)
 rename flang/lib/{Common => Support}/default-kinds.cpp (94%)
 rename flang/lib/{Common => Support}/idioms.cpp (89%)

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/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/flang/include/flang/Common/Fortran-consts.h b/FortranRuntime/include/flang/Common/Fortran-consts.h
similarity index 100%
rename from flang/include/flang/Common/Fortran-consts.h
rename to FortranRuntime/include/flang/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 95%
rename from flang/include/flang/ISO_Fortran_binding.h
rename to FortranRuntime/include/flang/Common/ISO_Fortran_binding.h
index 89a10ce69a2ba2..516355c01ec7d0 100644
--- a/flang/include/flang/ISO_Fortran_binding.h
+++ b/FortranRuntime/include/flang/Common/ISO_Fortran_binding.h
@@ -1,20 +1,19 @@
-/*===-- 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_
+#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
@@ -207,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/flang/include/flang/ISO_Fortran_binding_wrapper.h b/FortranRuntime/include/flang/Common/ISO_Fortran_binding_wrapper.h
similarity index 73%
rename from flang/include/flang/ISO_Fortran_binding_wrapper.h
rename to FortranRuntime/include/flang/Common/ISO_Fortran_binding_wrapper.h
index 37289bdbabd03c..d1bc9be34859a4 100644
--- a/flang/include/flang/ISO_Fortran_binding_wrapper.h
+++ b/FortranRuntime/include/flang/Common/ISO_Fortran_binding_wrapper.h
@@ -1,14 +1,13 @@
-/*===-- include/flang/ISO_Fortran_binding_wrapper.h ---------------*- C++ -*-===
+/*===-- include/flang/Common/ISO_Fortran_binding_wrapper.h ----------*- C -*-===
  *
  * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  * See https://llvm.org/LICENSE.txt for license information.
  * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  *
- * ===-----------------------------------------------------------------------===
- */
+ *===----------------------------------------------------------------------===*/
 
-#ifndef FORTRAN_ISO_FORTRAN_BINDING_WRAPPER_H_
-#define FORTRAN_ISO_FORTRAN_BINDING_WRAPPER_H_
+#ifndef FORTRAN_COMMON_ISO_FORTRAN_BINDING_WRAPPER_H_
+#define FORTRAN_COMMON_ISO_FORTRAN_BINDING_WRAPPER_H_
 
 /* A thin wrapper around flang/include/ISO_Fortran_binding.h
  * This header file must be included when ISO_Fortran_binding.h
@@ -23,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 {
@@ -36,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/flang/include/flang/Common/api-attrs.h b/FortranRuntime/include/flang/Common/api-attrs.h
similarity index 97%
rename from flang/include/flang/Common/api-attrs.h
rename to FortranRuntime/include/flang/Common/api-attrs.h
index d73e60996bc81f..9a3001fb255c11 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
@@ -13,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
@@ -178,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/flang/include/flang/Decimal/binary-floating-point.h b/FortranRuntime/include/flang/Common/binary-floating-point.h
similarity index 96%
rename from flang/include/flang/Decimal/binary-floating-point.h
rename to FortranRuntime/include/flang/Common/binary-floating-point.h
index 1e0cde97d98e61..705acc31bdfb21 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.
@@ -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/flang/include/flang/Common/bit-population-count.h b/FortranRuntime/include/flang/Common/bit-population-count.h
similarity index 98%
rename from flang/include/flang/Common/bit-population-count.h
rename to FortranRuntime/include/flang/Common/bit-population-count.h
index e1aeb78f9a3765..59ade914d14d85 100644
--- a/flang/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/flang/include/flang/Common/constexpr-bitset.h b/FortranRuntime/include/flang/Common/constexpr-bitset.h
similarity index 98%
rename from flang/include/flang/Common/constexpr-bitset.h
rename to FortranRuntime/include/flang/Common/constexpr-bitset.h
index 1aafb6eff84c61..093b247b5f4eff 100644
--- a/flang/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/flang/include/flang/Decimal/decimal.h b/FortranRuntime/include/flang/Common/decimal.h
similarity index 95%
rename from flang/include/flang/Decimal/decimal.h
rename to FortranRuntime/include/flang/Common/decimal.h
index 443163d058e28b..c086f97129f6a5 100644
--- a/flang/include/flang/Decimal/decimal.h
+++ b/FortranRuntime/include/flang/Common/decimal.h
@@ -1,16 +1,15 @@
-/*===-- 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. */
 
-#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>
@@ -137,4 +136,4 @@ RT_API_ATTRS enum NS(ConversionResultFlags) ConvertDecimalToLongDouble(
 #ifdef __cplusplus
 } // extern "C"
 #endif
-#endif
+#endif /* FORTRAN_COMMON_DECIMAL_H_ */
diff --git a/flang/include/flang/Common/enum-class.h b/FortranRuntime/include/flang/Common/enum-class.h
similarity index 98%
rename from flang/include/flang/Common/enum-class.h
rename to FortranRuntime/include/flang/Common/enum-class.h
index 41575d45091a8d..787648ffec48e8 100644
--- a/flang/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/flang/include/flang/Common/enum-set.h b/FortranRuntime/include/flang/Common/enum-set.h
similarity index 99%
rename from flang/include/flang/Common/enum-set.h
rename to FortranRuntime/include/flang/Common/enum-set.h
index 5290b76debee88..6100fc5e2e31c5 100644
--- a/flang/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/flang/include/flang/Common/fast-int-set.h b/FortranRuntime/include/flang/Common/fast-int-set.h
similarity index 97%
rename from flang/include/flang/Common/fast-int-set.h
rename to FortranRuntime/include/flang/Common/fast-int-set.h
index d1c9c756a44a65..323ee4dc7e94d9 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.
@@ -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/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 138e84b72b733d..6f4dfc8d2376b7 100644
--- a/flang/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/flang/include/flang/Common/idioms.h b/FortranRuntime/include/flang/Common/idioms.h
similarity index 99%
rename from flang/include/flang/Common/idioms.h
rename to FortranRuntime/include/flang/Common/idioms.h
index 99f383ec75b999..1ae0c0b35112e9 100644
--- a/flang/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/flang/include/flang/Common/leading-zero-bit-count.h b/FortranRuntime/include/flang/Common/leading-zero-bit-count.h
similarity index 98%
rename from flang/include/flang/Common/leading-zero-bit-count.h
rename to FortranRuntime/include/flang/Common/leading-zero-bit-count.h
index a296e0b446917f..e788bfa9bcfd08 100644
--- a/flang/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/flang/include/flang/Common/optional.h b/FortranRuntime/include/flang/Common/optional.h
similarity index 98%
rename from flang/include/flang/Common/optional.h
rename to FortranRuntime/include/flang/Common/optional.h
index c0f4278009f40a..c3db3b1329a2fd 100644
--- a/flang/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/flang/include/flang/Common/real.h b/FortranRuntime/include/flang/Common/real.h
similarity index 99%
rename from flang/include/flang/Common/real.h
rename to FortranRuntime/include/flang/Common/real.h
index b527deda0e3b4f..dc9a2404731e70 100644
--- a/flang/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/flang/include/flang/Common/reference-wrapper.h b/FortranRuntime/include/flang/Common/reference-wrapper.h
similarity index 96%
rename from flang/include/flang/Common/reference-wrapper.h
rename to FortranRuntime/include/flang/Common/reference-wrapper.h
index 2983754108f95a..6822fb335f398c 100644
--- a/flang/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/flang/include/flang/Common/restorer.h b/FortranRuntime/include/flang/Common/restorer.h
similarity index 97%
rename from flang/include/flang/Common/restorer.h
rename to FortranRuntime/include/flang/Common/restorer.h
index 0f1bc48620d37e..a5c5ebe7344a1b 100644
--- a/flang/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/flang/include/flang/Common/target-rounding.h b/FortranRuntime/include/flang/Common/target-rounding.h
similarity index 100%
rename from flang/include/flang/Common/target-rounding.h
rename to FortranRuntime/include/flang/Common/target-rounding.h
diff --git a/flang/include/flang/Common/uint128.h b/FortranRuntime/include/flang/Common/uint128.h
similarity index 99%
rename from flang/include/flang/Common/uint128.h
rename to FortranRuntime/include/flang/Common/uint128.h
index 821c8c3b08a52f..1b2ee6a2c14b87 100644
--- a/flang/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/flang/include/flang/Common/variant.h b/FortranRuntime/include/flang/Common/variant.h
similarity index 89%
rename from flang/include/flang/Common/variant.h
rename to FortranRuntime/include/flang/Common/variant.h
index 1af85876afac00..ff9b1aed4eba91 100644
--- a/flang/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/flang/include/flang/Common/visit.h b/FortranRuntime/include/flang/Common/visit.h
similarity index 98%
rename from flang/include/flang/Common/visit.h
rename to FortranRuntime/include/flang/Common/visit.h
index ad66297650b093..8030ac9be173c3 100644
--- a/flang/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/flang/include/flang/Common/windows-include.h b/FortranRuntime/include/flang/Common/windows-include.h
similarity index 93%
rename from flang/include/flang/Common/windows-include.h
rename to FortranRuntime/include/flang/Common/windows-include.h
index 75ef4974251ff9..bee79d4fceb3ba 100644
--- a/flang/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/flang/include/flang/Runtime/CUDA/allocator.h b/FortranRuntime/include/flang/Runtime/CUDA/allocator.h
similarity index 96%
rename from flang/include/flang/Runtime/CUDA/allocator.h
rename to FortranRuntime/include/flang/Runtime/CUDA/allocator.h
index 4527c9f18fa054..48185e8f34eaf6 100644
--- a/flang/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/flang/include/flang/Runtime/CUDA/descriptor.h b/FortranRuntime/include/flang/Runtime/CUDA/descriptor.h
similarity index 95%
rename from flang/include/flang/Runtime/CUDA/descriptor.h
rename to FortranRuntime/include/flang/Runtime/CUDA/descriptor.h
index d593989420420f..68ad0987d9aecd 100644
--- a/flang/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/flang/include/flang/Runtime/allocatable.h b/FortranRuntime/include/flang/Runtime/allocatable.h
similarity index 99%
rename from flang/include/flang/Runtime/allocatable.h
rename to FortranRuntime/include/flang/Runtime/allocatable.h
index 58061d9862095e..d7f3910074a760 100644
--- a/flang/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/flang/include/flang/Runtime/allocator-registry.h b/FortranRuntime/include/flang/Runtime/allocator-registry.h
similarity index 89%
rename from flang/include/flang/Runtime/allocator-registry.h
rename to FortranRuntime/include/flang/Runtime/allocator-registry.h
index acfada506fafc6..4e7d9bcedfb375 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.
@@ -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/flang/include/flang/Runtime/array-constructor.h b/FortranRuntime/include/flang/Runtime/array-constructor.h
similarity index 97%
rename from flang/include/flang/Runtime/array-constructor.h
rename to FortranRuntime/include/flang/Runtime/array-constructor.h
index 46fc0418c7991e..82367756f5dc79 100644
--- a/flang/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/flang/include/flang/Runtime/assign.h b/FortranRuntime/include/flang/Runtime/assign.h
similarity index 98%
rename from flang/include/flang/Runtime/assign.h
rename to FortranRuntime/include/flang/Runtime/assign.h
index a1cc9eaf4355f6..55d15a5c046868 100644
--- a/flang/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/flang/include/flang/Runtime/c-or-cpp.h b/FortranRuntime/include/flang/Runtime/c-or-cpp.h
similarity index 95%
rename from flang/include/flang/Runtime/c-or-cpp.h
rename to FortranRuntime/include/flang/Runtime/c-or-cpp.h
index 8bac523907750c..3c0c0be643cbc3 100644
--- a/flang/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/flang/include/flang/Runtime/character.h b/FortranRuntime/include/flang/Runtime/character.h
similarity index 99%
rename from flang/include/flang/Runtime/character.h
rename to FortranRuntime/include/flang/Runtime/character.h
index dd47686fe858fd..a842c30cd8120c 100644
--- a/flang/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/flang/include/flang/Runtime/command.h b/FortranRuntime/include/flang/Runtime/command.h
similarity index 98%
rename from flang/include/flang/Runtime/command.h
rename to FortranRuntime/include/flang/Runtime/command.h
index 7ab3f6442dcf92..2bbdfca7631163 100644
--- a/flang/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/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 27b43de7d0f0f6..7de1ea4f45f224 100644
--- a/flang/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/flang/include/flang/Runtime/derived-api.h b/FortranRuntime/include/flang/Runtime/derived-api.h
similarity index 98%
rename from flang/include/flang/Runtime/derived-api.h
rename to FortranRuntime/include/flang/Runtime/derived-api.h
index 79aa7d82de8819..ca1681e974051c 100644
--- a/flang/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/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..867f4d4ee29ac0 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>
@@ -492,4 +492,4 @@ class alignas(Descriptor) StaticDescriptor {
 };
 
 } // namespace Fortran::runtime
-#endif // FORTRAN_RUNTIME_DESCRIPTOR_H_
+#endif /* FORTRAN_RUNTIME_DESCRIPTOR_H_ */
diff --git a/flang/include/flang/Runtime/entry-names.h b/FortranRuntime/include/flang/Runtime/entry-names.h
similarity index 89%
rename from flang/include/flang/Runtime/entry-names.h
rename to FortranRuntime/include/flang/Runtime/entry-names.h
index 68582b92b54941..25134771bf9185 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
@@ -16,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"
 
@@ -41,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/flang/include/flang/Runtime/exceptions.h b/FortranRuntime/include/flang/Runtime/exceptions.h
similarity index 86%
rename from flang/include/flang/Runtime/exceptions.h
rename to FortranRuntime/include/flang/Runtime/exceptions.h
index 1ab22da103a50f..f2c67325b34d92 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.
@@ -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/flang/include/flang/Runtime/execute.h b/FortranRuntime/include/flang/Runtime/execute.h
similarity index 89%
rename from flang/include/flang/Runtime/execute.h
rename to FortranRuntime/include/flang/Runtime/execute.h
index ca137b9d1823c4..d1958a82594ffd 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.
@@ -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/flang/include/flang/Runtime/extensions.h b/FortranRuntime/include/flang/Runtime/extensions.h
similarity index 97%
rename from flang/include/flang/Runtime/extensions.h
rename to FortranRuntime/include/flang/Runtime/extensions.h
index fef651f3b2eedb..f46ccdd7d9528d 100644
--- a/flang/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/flang/include/flang/Runtime/freestanding-tools.h b/FortranRuntime/include/flang/Runtime/freestanding-tools.h
similarity index 99%
rename from flang/include/flang/Runtime/freestanding-tools.h
rename to FortranRuntime/include/flang/Runtime/freestanding-tools.h
index e94cb0a6c938cd..8aeef54ba0af3d 100644
--- a/flang/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/flang/include/flang/Runtime/inquiry.h b/FortranRuntime/include/flang/Runtime/inquiry.h
similarity index 91%
rename from flang/include/flang/Runtime/inquiry.h
rename to FortranRuntime/include/flang/Runtime/inquiry.h
index c7a7487f1a1b18..83b07cf2f31a47 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.
@@ -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/flang/include/flang/Runtime/io-api.h b/FortranRuntime/include/flang/Runtime/io-api.h
similarity index 99%
rename from flang/include/flang/Runtime/io-api.h
rename to FortranRuntime/include/flang/Runtime/io-api.h
index 328afc715a3f1e..367146a4925c53 100644
--- a/flang/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/flang/include/flang/Runtime/iostat.h b/FortranRuntime/include/flang/Runtime/iostat.h
similarity index 98%
rename from flang/include/flang/Runtime/iostat.h
rename to FortranRuntime/include/flang/Runtime/iostat.h
index 6ce7c82b424eb7..a5a2a560f05f8d 100644
--- a/flang/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/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 95%
rename from flang/include/flang/Runtime/main.h
rename to FortranRuntime/include/flang/Runtime/main.h
index 88232ea64fa6ab..98fcf1250d0ad6 100644
--- a/flang/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/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 97%
rename from flang/include/flang/Runtime/matmul-transpose.h
rename to FortranRuntime/include/flang/Runtime/matmul-transpose.h
index 2d79ca10e08958..077277fae2da86 100644
--- a/flang/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/flang/include/flang/Runtime/matmul.h b/FortranRuntime/include/flang/Runtime/matmul.h
similarity index 97%
rename from flang/include/flang/Runtime/matmul.h
rename to FortranRuntime/include/flang/Runtime/matmul.h
index a72d4a06ee4594..cd375ac43d77f2 100644
--- a/flang/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/flang/include/flang/Runtime/memory.h b/FortranRuntime/include/flang/Runtime/memory.h
similarity index 99%
rename from flang/include/flang/Runtime/memory.h
rename to FortranRuntime/include/flang/Runtime/memory.h
index 98412a989f890b..84af4d7189c074 100644
--- a/flang/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/flang/include/flang/Runtime/misc-intrinsic.h b/FortranRuntime/include/flang/Runtime/misc-intrinsic.h
similarity index 95%
rename from flang/include/flang/Runtime/misc-intrinsic.h
rename to FortranRuntime/include/flang/Runtime/misc-intrinsic.h
index 3fb3aaed49c0fb..1d4163c2e1e751 100644
--- a/flang/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/flang/include/flang/Runtime/numeric.h b/FortranRuntime/include/flang/Runtime/numeric.h
similarity index 99%
rename from flang/include/flang/Runtime/numeric.h
rename to FortranRuntime/include/flang/Runtime/numeric.h
index 84a5a7cd7a361c..5fbab2e069b739 100644
--- a/flang/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/flang/include/flang/Runtime/pointer.h b/FortranRuntime/include/flang/Runtime/pointer.h
similarity index 99%
rename from flang/include/flang/Runtime/pointer.h
rename to FortranRuntime/include/flang/Runtime/pointer.h
index 704144f08114f2..b7322ad92bd583 100644
--- a/flang/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/flang/include/flang/Runtime/ragged.h b/FortranRuntime/include/flang/Runtime/ragged.h
similarity index 96%
rename from flang/include/flang/Runtime/ragged.h
rename to FortranRuntime/include/flang/Runtime/ragged.h
index f52a619c55b43e..8574bc1fa110c8 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.
@@ -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/flang/include/flang/Runtime/random.h b/FortranRuntime/include/flang/Runtime/random.h
similarity index 93%
rename from flang/include/flang/Runtime/random.h
rename to FortranRuntime/include/flang/Runtime/random.h
index 269297dff47dba..bb6dcb3873f21d 100644
--- a/flang/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/flang/include/flang/Runtime/reduce.h b/FortranRuntime/include/flang/Runtime/reduce.h
similarity index 99%
rename from flang/include/flang/Runtime/reduce.h
rename to FortranRuntime/include/flang/Runtime/reduce.h
index 60f54c393b4bbd..ae2828f04bf7c0 100644
--- a/flang/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/flang/include/flang/Runtime/reduction.h b/FortranRuntime/include/flang/Runtime/reduction.h
similarity index 99%
rename from flang/include/flang/Runtime/reduction.h
rename to FortranRuntime/include/flang/Runtime/reduction.h
index 97986c12e8a10e..e00593fbc9f75e 100644
--- a/flang/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/flang/include/flang/Runtime/stop.h b/FortranRuntime/include/flang/Runtime/stop.h
similarity index 97%
rename from flang/include/flang/Runtime/stop.h
rename to FortranRuntime/include/flang/Runtime/stop.h
index f7c4ffe7403e8e..9ba41343c6f964 100644
--- a/flang/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/flang/include/flang/Runtime/support.h b/FortranRuntime/include/flang/Runtime/support.h
similarity index 94%
rename from flang/include/flang/Runtime/support.h
rename to FortranRuntime/include/flang/Runtime/support.h
index ba9c2598bb0ddd..9c9b067a18f2e4 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>
@@ -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/flang/include/flang/Runtime/temporary-stack.h b/FortranRuntime/include/flang/Runtime/temporary-stack.h
similarity index 98%
rename from flang/include/flang/Runtime/temporary-stack.h
rename to FortranRuntime/include/flang/Runtime/temporary-stack.h
index 3c1a4ea11a4352..f83fab7b0ac811 100644
--- a/flang/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/flang/include/flang/Runtime/time-intrinsic.h b/FortranRuntime/include/flang/Runtime/time-intrinsic.h
similarity index 97%
rename from flang/include/flang/Runtime/time-intrinsic.h
rename to FortranRuntime/include/flang/Runtime/time-intrinsic.h
index 80490a17e45597..0e63fc6a4647a4 100644
--- a/flang/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/flang/include/flang/Runtime/transformational.h b/FortranRuntime/include/flang/Runtime/transformational.h
similarity index 99%
rename from flang/include/flang/Runtime/transformational.h
rename to FortranRuntime/include/flang/Runtime/transformational.h
index a39b872f376a69..266dd9d7aebc24 100644
--- a/flang/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/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 dd3a9f2690ee74..ec359f25dbdd12 100644
--- a/flang/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/ISO_Fortran_binding_wrapper.h"
 #include "flang/Common/optional.h"
-#include "flang/ISO_Fortran_binding_wrapper.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/flang/unittests/Evaluate/fp-testing.h b/FortranRuntime/include/flang/Testing/fp-testing.h
similarity index 54%
rename from flang/unittests/Evaluate/fp-testing.h
rename to FortranRuntime/include/flang/Testing/fp-testing.h
index 9091963a99b32d..e223d2ef7d1b8b 100644
--- a/flang/unittests/Evaluate/fp-testing.h
+++ b/FortranRuntime/include/flang/Testing/fp-testing.h
@@ -1,5 +1,13 @@
-#ifndef FORTRAN_TEST_EVALUATE_FP_TESTING_H_
-#define FORTRAN_TEST_EVALUATE_FP_TESTING_H_
+//===-- include/flang/Testing/fp-testing.h ----------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef FORTRAN_TESTING_FP_TESTING_H_
+#define FORTRAN_TESTING_FP_TESTING_H_
 
 #include "flang/Common/target-rounding.h"
 #include <fenv.h>
@@ -24,4 +32,4 @@ class ScopedHostFloatingPointEnvironment {
 #endif
 };
 
-#endif // FORTRAN_TEST_EVALUATE_FP_TESTING_H_
+#endif /* FORTRAN_TESTING_FP_TESTING_H_ */
diff --git a/flang/unittests/Evaluate/testing.h b/FortranRuntime/include/flang/Testing/testing.h
similarity index 74%
rename from flang/unittests/Evaluate/testing.h
rename to FortranRuntime/include/flang/Testing/testing.h
index 422e2853c05bc6..404650c9a89f2c 100644
--- a/flang/unittests/Evaluate/testing.h
+++ b/FortranRuntime/include/flang/Testing/testing.h
@@ -1,5 +1,13 @@
-#ifndef FORTRAN_EVALUATE_TESTING_H_
-#define FORTRAN_EVALUATE_TESTING_H_
+//===-- include/flang/Testing/testing.h -------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef FORTRAN_TESTING_TESTING_H_
+#define FORTRAN_TESTING_TESTING_H_
 
 #include <cinttypes>
 #include <string>
@@ -33,4 +41,4 @@ FailureDetailPrinter Match(const char *file, int line, const std::string &want,
 FailureDetailPrinter Compare(const char *file, int line, const char *xs,
     const char *rel, const char *ys, std::uint64_t x, std::uint64_t y);
 } // namespace testing
-#endif // FORTRAN_EVALUATE_TESTING_H_
+#endif /* FORTRAN_TESTING_TESTING_H_ */
diff --git a/flang/lib/Decimal/big-radix-floating-point.h b/FortranRuntime/lib/Common/big-radix-floating-point.h
similarity index 97%
rename from flang/lib/Decimal/big-radix-floating-point.h
rename to FortranRuntime/lib/Common/big-radix-floating-point.h
index f9afebf5b3d703..6d247f3796eea5 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.
@@ -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/Decimal/binary-floating-point.h"
-#include "flang/Decimal/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/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..cbf1664e9c240d 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.
@@ -7,10 +7,10 @@
 //===----------------------------------------------------------------------===//
 
 #include "big-radix-floating-point.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/Decimal/binary-floating-point.h"
-#include "flang/Decimal/decimal.h"
 #include "flang/Runtime/freestanding-tools.h"
 #include <cinttypes>
 #include <cstring>
diff --git a/flang/runtime/CMakeLists.txt b/FortranRuntime/lib/Runtime/CMakeLists.txt
similarity index 98%
rename from flang/runtime/CMakeLists.txt
rename to FortranRuntime/lib/Runtime/CMakeLists.txt
index 4537b2d059d65b..8ecb08b4ebb8ae 100644
--- a/flang/runtime/CMakeLists.txt
+++ b/FortranRuntime/lib/Runtime/CMakeLists.txt
@@ -45,7 +45,8 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
     add_compile_definitions(FLANG_LITTLE_ENDIAN=1)
   endif ()
   include_directories(BEFORE
-    ${FLANG_SOURCE_DIR}/include)
+    ${FLANG_SOURCE_DIR}/include
+    ${FLANG_SOURCE_DIR}/../FortranRuntime/include)
 
   # The out of tree builds of the compiler and the Fortran runtime
   # must use the same setting of FLANG_RUNTIME_F128_MATH_LIB
@@ -89,7 +90,7 @@ else()
   set(NO_LTO_FLAGS "")
 endif()
 
-configure_file(config.h.cmake config.h)
+configure_file(../../cmake/config.h.cmake.in config.h)
 # include_directories is used here instead of target_include_directories
 # because add_flang_library creates multiple objects (STATIC/SHARED, OBJECT)
 # with different names
diff --git a/flang/runtime/CUDA/CMakeLists.txt b/FortranRuntime/lib/Runtime/CUDA/CMakeLists.txt
similarity index 100%
rename from flang/runtime/CUDA/CMakeLists.txt
rename to FortranRuntime/lib/Runtime/CUDA/CMakeLists.txt
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..2efd6bf0a95249 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,9 +11,9 @@
 #include "../stat.h"
 #include "../terminator.h"
 #include "../type-info.h"
-#include "flang/Common/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/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 100%
rename from flang/runtime/Float128Math/CMakeLists.txt
rename to FortranRuntime/lib/Runtime/Float128Math/CMakeLists.txt
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 98%
rename from flang/runtime/Float128Math/math-entries.h
rename to FortranRuntime/lib/Runtime/Float128Math/math-entries.h
index 13fdab26470038..cb1e0130602260 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.
@@ -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/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 92%
rename from flang/runtime/Float128Math/numeric-template-specs.h
rename to FortranRuntime/lib/Runtime/Float128Math/numeric-template-specs.h
index a0a77230c3e9eb..2a843df2d1d861 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.
@@ -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/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..9711b2bcf49757 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.
@@ -10,11 +10,11 @@
 // as specified in section 18.5.5 of Fortran 2018.
 
 #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"
+#include "terminator.h"
 #include <cstdlib>
 
 namespace Fortran::ISO {
diff --git a/flang/runtime/ISO_Fortran_util.h b/FortranRuntime/lib/Runtime/ISO_Fortran_util.h
similarity index 95%
rename from flang/runtime/ISO_Fortran_util.h
rename to FortranRuntime/lib/Runtime/ISO_Fortran_util.h
index dd0eeef80bb896..7ab280733028af 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.
@@ -11,10 +11,10 @@
 
 // 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 "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/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..8b6c1a4c1477eb 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.
@@ -9,12 +9,12 @@
 #include "flang/Runtime/allocatable.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/ISO_Fortran_binding_wrapper.h"
-#include "flang/Runtime/assign.h"
-#include "flang/Runtime/descriptor.h"
 
 namespace Fortran::runtime {
 extern "C" {
diff --git a/flang/runtime/allocator-registry.cpp b/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..db57d4fc4c3f68 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.
@@ -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/flang/runtime/assign-impl.h b/FortranRuntime/lib/Runtime/assign-impl.h
similarity index 89%
rename from flang/runtime/assign-impl.h
rename to FortranRuntime/lib/Runtime/assign-impl.h
index f07a501d1d1263..d5538fab18b6b5 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.
@@ -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/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..cc38e55e3a9e1e 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.
@@ -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/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 98%
rename from flang/runtime/buffer.h
rename to FortranRuntime/lib/Runtime/buffer.h
index 41a1abb1b2d907..dd3c19fa14392f 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.
@@ -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/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..32fc010c6c04dd 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.
@@ -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/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..dc57758d4f7955 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.
@@ -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/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..e8e287215b7d97 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
@@ -156,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/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 96%
rename from flang/runtime/connection.h
rename to FortranRuntime/lib/Runtime/connection.h
index 6f1ea90a160e5e..92a3a9c3860a3e 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.
@@ -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/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..39c7da45172a43 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.
@@ -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/flang/runtime/copy.h b/FortranRuntime/lib/Runtime/copy.h
similarity index 89%
rename from flang/runtime/copy.h
rename to FortranRuntime/lib/Runtime/copy.h
index 542660530bfb65..f2c5b41718b71c 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.
@@ -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/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..4b68cdbbed7b2c 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.
@@ -9,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/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..52bf54d62c8599 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.
@@ -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/flang/runtime/derived.h b/FortranRuntime/lib/Runtime/derived.h
similarity index 92%
rename from flang/runtime/derived.h
rename to FortranRuntime/lib/Runtime/derived.h
index b4863df8db417c..e03e657f01cee9 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.
@@ -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/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..2ccad0cea70a29 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.
@@ -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/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..6756134b06e7b1 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.
@@ -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/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..ab1cfa58ef3d02 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.
@@ -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/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..eaa9d0d7e641e7 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.
@@ -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/flang/runtime/edit-input.h b/FortranRuntime/lib/Runtime/edit-input.h
similarity index 93%
rename from flang/runtime/edit-input.h
rename to FortranRuntime/lib/Runtime/edit-input.h
index a90180b8ee2ebd..2eda81a6d4e11d 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.
@@ -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/Decimal/decimal.h"
 
 namespace Fortran::runtime::io {
 
@@ -50,4 +50,4 @@ extern template RT_API_ATTRS bool EditCharacterInput(
     IoStatementState &, const DataEdit &, char32_t *, std::size_t);
 
 } // namespace Fortran::runtime::io
-#endif // FORTRAN_RUNTIME_EDIT_INPUT_H_
+#endif /* FORTRAN_RUNTIME_EDIT_INPUT_H_ */
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..1fab7db6d3b187 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.
@@ -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/flang/runtime/edit-output.h b/FortranRuntime/lib/Runtime/edit-output.h
similarity index 97%
rename from flang/runtime/edit-output.h
rename to FortranRuntime/lib/Runtime/edit-output.h
index 365bc2e2a4d10b..cb25b68a35f05b 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.
@@ -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/Decimal/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/flang/runtime/emit-encoded.h b/FortranRuntime/lib/Runtime/emit-encoded.h
similarity index 97%
rename from flang/runtime/emit-encoded.h
rename to FortranRuntime/lib/Runtime/emit-encoded.h
index 4b5e3900788357..11163a41720795 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.
@@ -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/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 93%
rename from flang/runtime/environment.h
rename to FortranRuntime/lib/Runtime/environment.h
index b8b9f10e4e57f5..7d10b3a2b934bf 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.
@@ -9,8 +9,8 @@
 #ifndef FORTRAN_RUNTIME_ENVIRONMENT_H_
 #define FORTRAN_RUNTIME_ENVIRONMENT_H_
 
+#include "flang/Common/decimal.h"
 #include "flang/Common/optional.h"
-#include "flang/Decimal/decimal.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/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..54f28d052873b4 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.
@@ -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/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..94bfa3059e6b45 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.
@@ -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/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..0809cb1d5f2ae2 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.
@@ -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/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..b82f1c63e397f9 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.
@@ -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/flang/runtime/file.h b/FortranRuntime/lib/Runtime/file.h
similarity index 97%
rename from flang/runtime/file.h
rename to FortranRuntime/lib/Runtime/file.h
index c06acbb9904cc1..66d62756634b24 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.
@@ -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/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..47c51fbcef4939 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.
@@ -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/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..8d0d0f3376eafc 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.
@@ -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/Decimal/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/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 815bf70685e647..3e0807ee452a7e 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.
@@ -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/Decimal/decimal.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/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..172b46037d6c4b 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.
@@ -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/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..81b937ba63d4b8 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.
@@ -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/flang/runtime/internal-unit.h b/FortranRuntime/lib/Runtime/internal-unit.h
similarity index 90%
rename from flang/runtime/internal-unit.h
rename to FortranRuntime/lib/Runtime/internal-unit.h
index a0ee6353eeda3b..c4107696810f2b 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.
@@ -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/flang/runtime/io-api-common.h b/FortranRuntime/lib/Runtime/io-api-common.h
similarity index 94%
rename from flang/runtime/io-api-common.h
rename to FortranRuntime/lib/Runtime/io-api-common.h
index c7b86cab73a525..427666723501a2 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.
@@ -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/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..683694bd63c068 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.
@@ -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/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..102ea26b359111 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.
@@ -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/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..b14a30354d2347 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.
@@ -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/flang/runtime/io-error.h b/FortranRuntime/lib/Runtime/io-error.h
similarity index 96%
rename from flang/runtime/io-error.h
rename to FortranRuntime/lib/Runtime/io-error.h
index 426573e2faf00c..7388a2134ed0d3 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.
@@ -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/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..5be5d98ace0d8a 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.
@@ -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/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..79a8b28c8aa19f 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.
@@ -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/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 96%
rename from flang/runtime/lock.h
rename to FortranRuntime/lib/Runtime/lock.h
index 46ca28703a45b4..69ff6403736dae 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.
@@ -113,4 +113,4 @@ class CriticalSection {
 };
 } // namespace Fortran::runtime
 
-#endif // FORTRAN_RUNTIME_LOCK_H_
+#endif /* FORTRAN_RUNTIME_LOCK_H_ */
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..3b4b487daa335e 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.
@@ -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/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..62674316bc6a57 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.
@@ -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/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..bf2c4cd4a35470 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.
@@ -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/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..a0f41e4e3f156c 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.
@@ -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/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..1c8942fc375c43 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.
@@ -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/flang/runtime/namelist.h b/FortranRuntime/lib/Runtime/namelist.h
similarity index 94%
rename from flang/runtime/namelist.h
rename to FortranRuntime/lib/Runtime/namelist.h
index 25216a75e9367d..2c4d331ae05e85 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.
@@ -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/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 95%
rename from flang/runtime/non-tbp-dio.h
rename to FortranRuntime/lib/Runtime/non-tbp-dio.h
index 8429d790fea57a..426d5a92fd37d4 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.
@@ -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/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..f0045e8ee36e20 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.
@@ -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/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..a3fcfeaa9ee266 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.
@@ -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/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..8c11bf4144919e 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.
@@ -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/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 96%
rename from flang/runtime/random-templates.h
rename to FortranRuntime/lib/Runtime/random-templates.h
index f34422f6f5d9ac..801484225bc211 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.
@@ -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/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..8e1561960d48be 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.
@@ -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/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..4d33c2a714e5af 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.
@@ -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/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..30ae641ba7b3ac 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.
@@ -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/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..f4e1f2aa6818d5 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.
@@ -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/flang/runtime/stack.h b/FortranRuntime/lib/Runtime/stack.h
similarity index 95%
rename from flang/runtime/stack.h
rename to FortranRuntime/lib/Runtime/stack.h
index b6e6edb595e9ad..dc5b6101d3da0f 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.
@@ -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/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..01ae922e080865 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.
@@ -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/flang/runtime/stat.h b/FortranRuntime/lib/Runtime/stat.h
similarity index 93%
rename from flang/runtime/stat.h
rename to FortranRuntime/lib/Runtime/stat.h
index 71faeb027d9085..eccd69024d726b 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.
@@ -11,8 +11,8 @@
 
 #ifndef FORTRAN_RUNTIME_STAT_H_
 #define FORTRAN_RUNTIME_STAT_H_
+#include "flang/Common/ISO_Fortran_binding_wrapper.h"
 #include "flang/Common/api-attrs.h"
-#include "flang/ISO_Fortran_binding_wrapper.h"
 #include "flang/Runtime/magic-numbers.h"
 namespace Fortran::runtime {
 
@@ -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/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..e33b77e20f0f11 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.
@@ -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/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..0a39ff24b0cafc 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.
@@ -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/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..f944dfb7aa1471 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.
@@ -10,11 +10,11 @@
 // temporaries. For use in HLFIR lowering.
 
 #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"
+#include "terminator.h"
 
 namespace {
 
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 97%
rename from flang/runtime/terminator.h
rename to FortranRuntime/lib/Runtime/terminator.h
index 609f059d6e0921..f475658b0eab3d 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.
@@ -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/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..4b362c90c52f25 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.
@@ -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/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..4058767ca283a9 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.
@@ -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/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..66dc5bd4939bae 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.
@@ -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/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 32403b1db5169e..ff3523bcb2b8eb 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.
@@ -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/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 96%
rename from flang/runtime/unit-map.h
rename to FortranRuntime/lib/Runtime/unit-map.h
index 6f1e01bb1e64ac..4e61246f9a2d86 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.
@@ -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/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 98%
rename from flang/runtime/unit.h
rename to FortranRuntime/lib/Runtime/unit.h
index a3ea2686816803..993fbf2977cebf 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.
@@ -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/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 96%
rename from flang/runtime/utf.h
rename to FortranRuntime/lib/Runtime/utf.h
index 10c2d61484217a..35c03fd4cdded5 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.
@@ -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/flang/unittests/Evaluate/fp-testing.cpp b/FortranRuntime/lib/Testing/fp-testing.cpp
similarity index 98%
rename from flang/unittests/Evaluate/fp-testing.cpp
rename to FortranRuntime/lib/Testing/fp-testing.cpp
index 1a1d7425d58249..3301d2d8efb15f 100644
--- a/flang/unittests/Evaluate/fp-testing.cpp
+++ b/FortranRuntime/lib/Testing/fp-testing.cpp
@@ -1,4 +1,4 @@
-#include "fp-testing.h"
+#include "flang/Testing/fp-testing.h"
 #include "llvm/Support/Errno.h"
 #include <cstdio>
 #include <cstdlib>
@@ -7,8 +7,8 @@
 #include <xmmintrin.h>
 #endif
 
-using Fortran::common::RealFlag;
 using Fortran::common::RoundingMode;
+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/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/flang/unittests/Common/CMakeLists.txt b/FortranRuntime/unittests/Common/CMakeLists.txt
similarity index 100%
rename from flang/unittests/Common/CMakeLists.txt
rename to FortranRuntime/unittests/Common/CMakeLists.txt
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..a36a334e370eb9 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.
@@ -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/flang/unittests/Decimal/CMakeLists.txt b/FortranRuntime/unittests/Decimal/CMakeLists.txt
similarity index 100%
rename from flang/unittests/Decimal/CMakeLists.txt
rename to FortranRuntime/unittests/Decimal/CMakeLists.txt
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..b4cc72b748efd5
--- /dev/null
+++ b/FortranRuntime/unittests/Evaluate/CMakeLists.txt
@@ -0,0 +1,6 @@
+add_flang_nongtest_unittest(reshape
+  FortranEvaluateTesting
+  FortranSemantics
+  FortranEvaluate
+  FortranRuntime
+)
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..d2546e0c22d2d6 100644
--- a/flang/unittests/Evaluate/ISO-Fortran-binding.cpp
+++ b/FortranRuntime/unittests/Evaluate/ISO-Fortran-binding.cpp
@@ -1,6 +1,14 @@
-#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/Common/ISO_Fortran_binding_wrapper.h"
 #include "flang/Runtime/descriptor.h"
+#include "flang/Testing/testing.h"
 #include "llvm/Support/raw_ostream.h"
 #include <type_traits>
 
diff --git a/flang/unittests/Evaluate/reshape.cpp b/FortranRuntime/unittests/Evaluate/reshape.cpp
similarity index 88%
rename from flang/unittests/Evaluate/reshape.cpp
rename to FortranRuntime/unittests/Evaluate/reshape.cpp
index 5d138cd3d88d98..a93afd2a3c90cd 100644
--- a/flang/unittests/Evaluate/reshape.cpp
+++ b/FortranRuntime/unittests/Evaluate/reshape.cpp
@@ -1,6 +1,14 @@
-#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/Runtime/descriptor.h"
 #include "flang/Runtime/transformational.h"
+#include "flang/Testing/testing.h"
 #include <cinttypes>
 
 using namespace Fortran::common;
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..3e9feaf945b66d 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.
@@ -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/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..c01f85598d21ed 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.
@@ -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/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..9011da304b6bc3 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.
@@ -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/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 100%
rename from flang/unittests/Runtime/CMakeLists.txt
rename to FortranRuntime/unittests/Runtime/CMakeLists.txt
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..d2c1600af8c631 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.
@@ -6,13 +6,13 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "gtest/gtest.h"
 #include "../../../runtime/terminator.h"
-#include "flang/Common/Fortran.h"
 #include "flang/Runtime/CUDA/allocator.h"
 #include "flang/Runtime/CUDA/descriptor.h"
 #include "flang/Runtime/allocatable.h"
 #include "flang/Runtime/allocator-registry.h"
+#include "flang/Support/Fortran.h"
+#include "gtest/gtest.h"
 
 #include "cuda_runtime.h"
 
diff --git a/flang/unittests/Runtime/CUDA/CMakeLists.txt b/FortranRuntime/unittests/Runtime/CUDA/CMakeLists.txt
similarity index 100%
rename from flang/unittests/Runtime/CUDA/CMakeLists.txt
rename to FortranRuntime/unittests/Runtime/CUDA/CMakeLists.txt
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..8829f5e43265b0 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.
@@ -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/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..aa79ce381ba8d0 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.
@@ -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/flang/unittests/Runtime/Complex.cpp b/FortranRuntime/unittests/Runtime/Complex.cpp
similarity index 100%
rename from flang/unittests/Runtime/Complex.cpp
rename to FortranRuntime/unittests/Runtime/Complex.cpp
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 70%
rename from flang/unittests/Runtime/CrashHandlerFixture.h
rename to FortranRuntime/unittests/Runtime/CrashHandlerFixture.h
index fe0ee0da5204e4..46805775af0b39 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.
@@ -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/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..11b732fe10b790 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.
@@ -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/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..00c2fd76ce0c04 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.
@@ -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/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..204a97a1088ac0 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.
@@ -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/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..4c30d6ed750141 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.
@@ -6,8 +6,8 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "../../lib/Runtime/io-error.h"
 #include "CrashHandlerFixture.h"
-#include "../../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..cfa5d18cc36d33 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.
@@ -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/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..146c2283fb1aca 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.
@@ -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/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..08229b5e48f0dd 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.
@@ -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/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..7b834dec49c3c4 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,11 +6,11 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "../../runtime/namelist.h"
+#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/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..fb595ae262c324 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.
@@ -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/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..a05bd70a64bb9f 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.
@@ -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/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..4e4b59cbcf40e7 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.
@@ -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/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..c35f6e2fa6a41b 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.
@@ -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/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..61580a8d46792f 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.
@@ -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 "../../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/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..5fd8deaad21d6b 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.
@@ -10,8 +10,8 @@
 //
 //===----------------------------------------------------------------------===//
 #include "flang/Runtime/stop.h"
+#include "../../lib/Runtime/environment.h"
 #include "CrashHandlerFixture.h"
-#include "../../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..38c0d6efaf9db7 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.
@@ -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/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..63d99416ea64cb 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.
@@ -6,14 +6,14 @@
 //
 //===----------------------------------------------------------------------===//
 
-#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"
 #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/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..6fd00d669a9575 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.
@@ -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/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..b5a4e0e8e9588b 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.
@@ -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/flang/unittests/Runtime/tools.h b/FortranRuntime/unittests/Runtime/tools.h
similarity index 93%
rename from flang/unittests/Runtime/tools.h
rename to FortranRuntime/unittests/Runtime/tools.h
index 0347edace5c05c..702103d225ab72 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.
@@ -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 971e5d5c93f231..a7f23ee59d192c 100644
--- a/flang/CMakeLists.txt
+++ b/flang/CMakeLists.txt
@@ -257,7 +257,8 @@ set(LLVM_BUILD_TOOLS ON)
 
 include_directories(BEFORE
   ${FLANG_BINARY_DIR}/include
-  ${FLANG_SOURCE_DIR}/include)
+  ${FLANG_SOURCE_DIR}/include
+  ${FLANG_SOURCE_DIR}/../FortranRuntime/include)
 
 # Add Flang-centric modules to cmake path.
 list(INSERT CMAKE_MODULE_PATH 0
@@ -468,7 +469,7 @@ if (FLANG_CUF_RUNTIME)
   find_package(CUDAToolkit REQUIRED)
 endif()
 
-add_subdirectory(runtime)
+add_subdirectory(../FortranRuntime/lib/Runtime runtime)
 
 if (LLVM_INCLUDE_EXAMPLES)
   add_subdirectory(examples)
@@ -537,7 +538,7 @@ endif()
 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
+  ../FortranRuntime/include/flang/Common/ISO_Fortran_binding.h
   ${HEADER_BINARY_DIR}/ISO_Fortran_binding.h)
 
 # And also install it into the install area
diff --git a/flang/include/flang/Evaluate/call.h b/flang/include/flang/Evaluate/call.h
index 7531d8a81e808d..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/Common/Fortran.h"
-#include "flang/Common/indirection.h"
-#include "flang/Common/reference.h"
 #include "flang/Parser/char-block.h"
 #include "flang/Semantics/attr.h"
+#include "flang/Support/Fortran.h"
+#include "flang/Support/indirection.h"
+#include "flang/Support/reference.h"
 #include <optional>
 #include <vector>
 
diff --git a/flang/include/flang/Evaluate/characteristics.h b/flang/include/flang/Evaluate/characteristics.h
index 11533a7259b055..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/Common/Fortran-features.h"
-#include "flang/Common/Fortran.h"
 #include "flang/Common/enum-set.h"
 #include "flang/Common/idioms.h"
-#include "flang/Common/indirection.h"
 #include "flang/Parser/char-block.h"
 #include "flang/Semantics/symbol.h"
+#include "flang/Support/Fortran-features.h"
+#include "flang/Support/Fortran.h"
+#include "flang/Support/indirection.h"
 #include <optional>
 #include <string>
 #include <variant>
diff --git a/flang/include/flang/Evaluate/common.h b/flang/include/flang/Evaluate/common.h
index 915e95169c7f81..91d38748f5a575 100644
--- a/flang/include/flang/Evaluate/common.h
+++ b/flang/include/flang/Evaluate/common.h
@@ -9,16 +9,16 @@
 #ifndef FORTRAN_EVALUATE_COMMON_H_
 #define FORTRAN_EVALUATE_COMMON_H_
 
-#include "flang/Common/Fortran-features.h"
-#include "flang/Common/Fortran.h"
-#include "flang/Common/default-kinds.h"
 #include "flang/Common/enum-set.h"
 #include "flang/Common/idioms.h"
-#include "flang/Common/indirection.h"
 #include "flang/Common/restorer.h"
 #include "flang/Common/target-rounding.h"
 #include "flang/Parser/char-block.h"
 #include "flang/Parser/message.h"
+#include "flang/Support/Fortran-features.h"
+#include "flang/Support/Fortran.h"
+#include "flang/Support/default-kinds.h"
+#include "flang/Support/indirection.h"
 #include <cinttypes>
 #include <map>
 #include <set>
diff --git a/flang/include/flang/Evaluate/constant.h b/flang/include/flang/Evaluate/constant.h
index 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..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/Common/Fortran.h"
 #include "flang/Common/idioms.h"
-#include "flang/Common/indirection.h"
-#include "flang/Common/template.h"
 #include "flang/Parser/char-block.h"
+#include "flang/Support/Fortran.h"
+#include "flang/Support/indirection.h"
+#include "flang/Support/template.h"
 #include <algorithm>
 #include <list>
 #include <tuple>
diff --git a/flang/include/flang/Evaluate/formatting.h b/flang/include/flang/Evaluate/formatting.h
index 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..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/Common/default-kinds.h"
 #include "flang/Parser/char-block.h"
 #include "flang/Parser/message.h"
+#include "flang/Support/default-kinds.h"
 #include <memory>
 #include <optional>
 #include <string>
diff --git a/flang/include/flang/Evaluate/shape.h b/flang/include/flang/Evaluate/shape.h
index e33044c0d34e56..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/Common/indirection.h"
 #include "flang/Evaluate/type.h"
+#include "flang/Support/indirection.h"
 #include <optional>
 #include <variant>
 
diff --git a/flang/include/flang/Evaluate/target.h b/flang/include/flang/Evaluate/target.h
index 1950a4cb6bfc76..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/Common/Fortran.h"
 #include "flang/Common/enum-class.h"
 #include "flang/Common/enum-set.h"
 #include "flang/Common/target-rounding.h"
 #include "flang/Evaluate/common.h"
+#include "flang/Support/Fortran.h"
 #include <cstdint>
 
 namespace Fortran::evaluate {
diff --git a/flang/include/flang/Evaluate/tools.h b/flang/include/flang/Evaluate/tools.h
index a0487e399d936c..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/Common/template.h"
-#include "flang/Common/unwrap.h"
 #include "flang/Evaluate/constant.h"
 #include "flang/Evaluate/expression.h"
 #include "flang/Evaluate/shape.h"
@@ -21,6 +19,8 @@
 #include "flang/Semantics/attr.h"
 #include "flang/Semantics/scope.h"
 #include "flang/Semantics/symbol.h"
+#include "flang/Support/template.h"
+#include "flang/Support/unwrap.h"
 #include <array>
 #include <optional>
 #include <set>
diff --git a/flang/include/flang/Evaluate/traverse.h b/flang/include/flang/Evaluate/traverse.h
index 7f4a67d97e64e7..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/Common/indirection.h"
 #include "flang/Semantics/symbol.h"
 #include "flang/Semantics/type.h"
+#include "flang/Support/indirection.h"
 #include <set>
 #include <type_traits>
 
diff --git a/flang/include/flang/Evaluate/type.h b/flang/include/flang/Evaluate/type.h
index bd8887dbce4e82..93311e3d2e5ae0 100644
--- a/flang/include/flang/Evaluate/type.h
+++ b/flang/include/flang/Evaluate/type.h
@@ -22,11 +22,11 @@
 #include "integer.h"
 #include "logical.h"
 #include "real.h"
-#include "flang/Common/Fortran-features.h"
-#include "flang/Common/Fortran.h"
 #include "flang/Common/idioms.h"
 #include "flang/Common/real.h"
-#include "flang/Common/template.h"
+#include "flang/Support/Fortran-features.h"
+#include "flang/Support/Fortran.h"
+#include "flang/Support/template.h"
 #include <cinttypes>
 #include <optional>
 #include <string>
diff --git a/flang/include/flang/Evaluate/variable.h b/flang/include/flang/Evaluate/variable.h
index 9565826dbfaea4..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/Common/reference.h"
-#include "flang/Common/template.h"
 #include "flang/Parser/char-block.h"
+#include "flang/Support/reference.h"
+#include "flang/Support/template.h"
 #include <optional>
 #include <variant>
 #include <vector>
diff --git a/flang/include/flang/Frontend/FrontendOptions.h b/flang/include/flang/Frontend/FrontendOptions.h
index 82ca99672ec610..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/Common/Fortran-features.h"
 #include "flang/Lower/EnvironmentDefault.h"
 #include "flang/Parser/characters.h"
 #include "flang/Parser/unparse.h"
+#include "flang/Support/Fortran-features.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include <cstdint>
diff --git a/flang/include/flang/Lower/AbstractConverter.h b/flang/include/flang/Lower/AbstractConverter.h
index daded9091780e2..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/Common/Fortran.h"
 #include "flang/Lower/LoweringOptions.h"
 #include "flang/Lower/PFTDefs.h"
 #include "flang/Optimizer/Builder/BoxValue.h"
 #include "flang/Optimizer/Dialect/FIRAttr.h"
 #include "flang/Semantics/symbol.h"
+#include "flang/Support/Fortran.h"
 #include "mlir/IR/Builders.h"
 #include "mlir/IR/BuiltinOps.h"
 #include "mlir/IR/Operation.h"
diff --git a/flang/include/flang/Lower/Bridge.h b/flang/include/flang/Lower/Bridge.h
index 4379ed512cdf0a..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/Common/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 9a688330e8bd2d..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/Common/reference.h"
 #include "flang/Evaluate/characteristics.h"
+#include "flang/Support/reference.h"
 #include "mlir/Dialect/Func/IR/FuncOps.h"
 #include "mlir/IR/BuiltinOps.h"
 #include <memory>
diff --git a/flang/include/flang/Lower/ConvertType.h b/flang/include/flang/Lower/ConvertType.h
index 7a3f92649a4e4a..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/Common/Fortran.h"
 #include "flang/Evaluate/type.h"
+#include "flang/Support/Fortran.h"
 #include "mlir/IR/BuiltinTypes.h"
 
 namespace mlir {
diff --git a/flang/include/flang/Lower/LoweringOptions.h b/flang/include/flang/Lower/LoweringOptions.h
index 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..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/Common/reference.h"
-#include "flang/Common/template.h"
 #include "flang/Lower/HostAssociations.h"
 #include "flang/Lower/PFTDefs.h"
 #include "flang/Parser/parse-tree.h"
@@ -26,6 +24,8 @@
 #include "flang/Semantics/scope.h"
 #include "flang/Semantics/semantics.h"
 #include "flang/Semantics/symbol.h"
+#include "flang/Support/reference.h"
+#include "flang/Support/template.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/raw_ostream.h"
 
diff --git a/flang/include/flang/Lower/Support/Utils.h b/flang/include/flang/Lower/Support/Utils.h
index 1cc74521e22d88..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/Common/indirection.h"
 #include "flang/Parser/char-block.h"
 #include "flang/Semantics/tools.h"
+#include "flang/Support/indirection.h"
 #include "mlir/Dialect/Arith/IR/Arith.h"
 #include "mlir/Dialect/Func/IR/FuncOps.h"
 #include "mlir/IR/BuiltinAttributes.h"
diff --git a/flang/include/flang/Lower/SymbolMap.h b/flang/include/flang/Lower/SymbolMap.h
index c03f9afd40801c..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/Common/reference.h"
 #include "flang/Optimizer/Builder/BoxValue.h"
 #include "flang/Optimizer/Dialect/FIRType.h"
 #include "flang/Optimizer/Dialect/FortranVariableInterface.h"
 #include "flang/Optimizer/Support/Matcher.h"
 #include "flang/Semantics/symbol.h"
+#include "flang/Support/reference.h"
 #include "mlir/IR/Value.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/DenseMap.h"
diff --git a/flang/include/flang/Optimizer/Builder/FIRBuilder.h b/flang/include/flang/Optimizer/Builder/FIRBuilder.h
index f7151f26f09cb3..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/Common/MathOptionsBase.h"
 #include "flang/Optimizer/Dialect/FIROps.h"
 #include "flang/Optimizer/Dialect/FIROpsSupport.h"
 #include "flang/Optimizer/Dialect/FIRType.h"
 #include "flang/Optimizer/Dialect/Support/FIRContext.h"
 #include "flang/Optimizer/Dialect/Support/KindMapping.h"
+#include "flang/Support/MathOptionsBase.h"
 #include "mlir/IR/Builders.h"
 #include "mlir/IR/BuiltinOps.h"
 #include "llvm/ADT/DenseMap.h"
diff --git a/flang/include/flang/Optimizer/Builder/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..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/Common/static-multimap-view.h"
 #include "flang/Optimizer/Builder/IntrinsicCall.h"
+#include "flang/Support/static-multimap-view.h"
 #include "mlir/Dialect/Math/IR/Math.h"
 
 namespace fir {
diff --git a/flang/include/flang/Optimizer/Builder/Runtime/RTBuilder.h b/flang/include/flang/Optimizer/Builder/Runtime/RTBuilder.h
index a103861f1510b8..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/Common/Fortran.h"
 #include "flang/Common/uint128.h"
 #include "flang/Optimizer/Builder/FIRBuilder.h"
 #include "flang/Optimizer/Dialect/FIRDialect.h"
 #include "flang/Optimizer/Dialect/FIRType.h"
 #include "flang/Runtime/reduce.h"
+#include "flang/Support/Fortran.h"
 #include "mlir/IR/BuiltinTypes.h"
 #include "mlir/IR/MLIRContext.h"
 #include "llvm/ADT/SmallVector.h"
diff --git a/flang/include/flang/Optimizer/CodeGen/DescriptorModel.h b/flang/include/flang/Optimizer/CodeGen/DescriptorModel.h
index 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..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/Common/default-kinds.h"
 #include "flang/Optimizer/Builder/FIRBuilder.h"
 #include "flang/Optimizer/Builder/Todo.h"
 #include "flang/Optimizer/Dialect/CUF/Attributes/CUFAttr.h"
 #include "flang/Optimizer/Dialect/FIROps.h"
 #include "flang/Optimizer/Dialect/FIRType.h"
 #include "flang/Optimizer/Support/FatalError.h"
+#include "flang/Support/default-kinds.h"
 #include "mlir/Dialect/Arith/IR/Arith.h"
 #include "mlir/Dialect/Func/IR/FuncOps.h"
 #include "mlir/IR/BuiltinAttributes.h"
diff --git a/flang/include/flang/Parser/char-block.h b/flang/include/flang/Parser/char-block.h
index 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..30ea08806430a9 100644
--- a/flang/include/flang/Parser/dump-parse-tree.h
+++ b/flang/include/flang/Parser/dump-parse-tree.h
@@ -14,9 +14,9 @@
 #include "parse-tree.h"
 #include "tools.h"
 #include "unparse.h"
-#include "flang/Common/Fortran.h"
 #include "flang/Common/idioms.h"
-#include "flang/Common/indirection.h"
+#include "flang/Support/Fortran.h"
+#include "flang/Support/indirection.h"
 #include "llvm/Support/raw_ostream.h"
 #include <string>
 #include <type_traits>
diff --git a/flang/include/flang/Parser/message.h b/flang/include/flang/Parser/message.h
index 668559aeec9478..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/Common/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 76cbb3470dc08d..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/Common/Fortran-features.h"
 #include "flang/Common/idioms.h"
 #include "flang/Parser/characters.h"
 #include "flang/Parser/message.h"
 #include "flang/Parser/provenance.h"
+#include "flang/Support/Fortran-features.h"
 #include <cstddef>
 #include <cstring>
 #include <list>
diff --git a/flang/include/flang/Parser/parse-tree.h b/flang/include/flang/Parser/parse-tree.h
index 548fcc81984b2a..de869f8200a261 100644
--- a/flang/include/flang/Parser/parse-tree.h
+++ b/flang/include/flang/Parser/parse-tree.h
@@ -22,9 +22,9 @@
 #include "format-specification.h"
 #include "message.h"
 #include "provenance.h"
-#include "flang/Common/Fortran.h"
 #include "flang/Common/idioms.h"
-#include "flang/Common/indirection.h"
+#include "flang/Support/Fortran.h"
+#include "flang/Support/indirection.h"
 #include "llvm/Frontend/OpenACC/ACC.h.inc"
 #include "llvm/Frontend/OpenMP/OMPConstants.h"
 #include <cinttypes>
diff --git a/flang/include/flang/Parser/parsing.h b/flang/include/flang/Parser/parsing.h
index 4d329c189cb80e..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/Common/Fortran-features.h"
 #include "flang/Parser/preprocessor.h"
+#include "flang/Support/Fortran-features.h"
 #include "llvm/Support/raw_ostream.h"
 #include <optional>
 #include <string>
diff --git a/flang/include/flang/Parser/provenance.h b/flang/include/flang/Parser/provenance.h
index 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..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/Common/Fortran-features.h"
 #include "flang/Common/idioms.h"
 #include "flang/Parser/char-block.h"
 #include "flang/Parser/parse-tree.h"
+#include "flang/Support/Fortran-features.h"
 #include "llvm/Support/raw_ostream.h"
 #include <cinttypes>
 #include <optional>
diff --git a/flang/include/flang/Semantics/expression.h b/flang/include/flang/Semantics/expression.h
index c90c8c4b3cc70f..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/Common/Fortran.h"
-#include "flang/Common/indirection.h"
 #include "flang/Common/restorer.h"
 #include "flang/Common/visit.h"
 #include "flang/Evaluate/characteristics.h"
@@ -24,6 +22,8 @@
 #include "flang/Parser/parse-tree-visitor.h"
 #include "flang/Parser/parse-tree.h"
 #include "flang/Parser/tools.h"
+#include "flang/Support/Fortran.h"
+#include "flang/Support/indirection.h"
 #include <map>
 #include <optional>
 #include <type_traits>
diff --git a/flang/include/flang/Semantics/runtime-type-info.h b/flang/include/flang/Semantics/runtime-type-info.h
index e90d3ae8baf1eb..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/Common/reference.h"
 #include "flang/Semantics/symbol.h"
+#include "flang/Support/reference.h"
 #include <map>
 #include <set>
 #include <string>
diff --git a/flang/include/flang/Semantics/scope.h b/flang/include/flang/Semantics/scope.h
index e73a507e9b3f5b..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/Common/Fortran.h"
 #include "flang/Common/idioms.h"
-#include "flang/Common/reference.h"
 #include "flang/Parser/message.h"
 #include "flang/Parser/provenance.h"
+#include "flang/Support/Fortran.h"
+#include "flang/Support/reference.h"
 #include <list>
 #include <map>
 #include <optional>
diff --git a/flang/include/flang/Semantics/semantics.h b/flang/include/flang/Semantics/semantics.h
index e73f9d2e85d589..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/Common/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 b4db6689a94271..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/Common/Fortran.h"
 #include "flang/Common/enum-set.h"
-#include "flang/Common/reference.h"
 #include "flang/Common/visit.h"
 #include "flang/Semantics/module-dependences.h"
+#include "flang/Support/Fortran.h"
+#include "flang/Support/reference.h"
 #include "llvm/ADT/DenseMapInfo.h"
 
 #include <array>
diff --git a/flang/include/flang/Semantics/tools.h b/flang/include/flang/Semantics/tools.h
index 15c02ecc0058cc..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/Common/Fortran.h"
 #include "flang/Common/visit.h"
 #include "flang/Evaluate/expression.h"
 #include "flang/Evaluate/shape.h"
@@ -23,6 +22,7 @@
 #include "flang/Semantics/attr.h"
 #include "flang/Semantics/expression.h"
 #include "flang/Semantics/semantics.h"
+#include "flang/Support/Fortran.h"
 #include <functional>
 
 namespace Fortran::semantics {
diff --git a/flang/include/flang/Semantics/type.h b/flang/include/flang/Semantics/type.h
index e2d47d38f927f7..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/Common/Fortran.h"
 #include "flang/Common/idioms.h"
 #include "flang/Evaluate/expression.h"
 #include "flang/Parser/char-block.h"
+#include "flang/Support/Fortran.h"
 #include <algorithm>
 #include <iosfwd>
 #include <map>
diff --git a/flang/include/flang/Common/Fortran-features.h b/flang/include/flang/Support/Fortran-features.h
similarity index 98%
rename from flang/include/flang/Common/Fortran-features.h
rename to flang/include/flang/Support/Fortran-features.h
index 86c6e02b0f2ffd..718ce680afeeab 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,9 +9,9 @@
 #ifndef FORTRAN_COMMON_FORTRAN_FEATURES_H_
 #define FORTRAN_COMMON_FORTRAN_FEATURES_H_
 
-#include "flang/Common/Fortran.h"
 #include "flang/Common/enum-set.h"
 #include "flang/Common/idioms.h"
+#include "flang/Support/Fortran.h"
 #include <vector>
 
 namespace Fortran::common {
diff --git a/flang/include/flang/Common/Fortran.h b/flang/include/flang/Support/Fortran.h
similarity index 98%
rename from flang/include/flang/Common/Fortran.h
rename to flang/include/flang/Support/Fortran.h
index 623607d4fad267..343a0b30d2ba9c 100644
--- a/flang/include/flang/Common/Fortran.h
+++ b/flang/include/flang/Support/Fortran.h
@@ -12,9 +12,9 @@
 // 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>
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..58c9b0a5628e8a 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,8 +9,8 @@
 #ifndef FORTRAN_COMMON_TEMPLATE_H_
 #define FORTRAN_COMMON_TEMPLATE_H_
 
-#include "variant.h"
 #include "flang/Common/idioms.h"
+#include "flang/Common/variant.h"
 #include <functional>
 #include <optional>
 #include <tuple>
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..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/Common/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 c6f818ad27cd19..ff7c186bff866b 100644
--- a/flang/lib/Common/CMakeLists.txt
+++ b/flang/lib/Common/CMakeLists.txt
@@ -36,11 +36,11 @@ endif()
 
 
 add_flang_library(FortranCommon
-  Fortran.cpp
-  Fortran-features.cpp
-  default-kinds.cpp
-  idioms.cpp
-  Version.cpp
+  ../Support/Fortran.cpp
+  ../Support/Fortran-features.cpp
+  ../Support/default-kinds.cpp
+  ../Support/idioms.cpp
+  ../Support/Version.cpp
   ${version_inc}
 
   LINK_COMPONENTS
diff --git a/flang/lib/Decimal/CMakeLists.txt b/flang/lib/Decimal/CMakeLists.txt
index 880b190f1c5815..6b058e4a0ae2fa 100644
--- a/flang/lib/Decimal/CMakeLists.txt
+++ b/flang/lib/Decimal/CMakeLists.txt
@@ -37,7 +37,8 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
     add_compile_definitions(FLANG_LITTLE_ENDIAN=1)
   endif ()
   include_directories(BEFORE
-    ${FLANG_SOURCE_DIR}/include)
+    ${FLANG_SOURCE_DIR}/include
+    ${FLANG_SOURCE_DIR}/../FortranRuntime/include)
 endif()
 
 check_cxx_compiler_flag(-fno-lto FLANG_RUNTIME_HAS_FNO_LTO_FLAG)
@@ -50,8 +51,8 @@ endif()
 add_definitions(-U_GLIBCXX_ASSERTIONS)
 
 set(sources
-  binary-to-decimal.cpp
-  decimal-to-binary.cpp
+  ../../../FortranRuntime/lib/Common/binary-to-decimal.cpp
+  ../../../FortranRuntime/lib/Common/decimal-to-binary.cpp
 )
 
 include(AddFlangOffloadRuntime)
@@ -63,23 +64,23 @@ 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
+          ../../../FortranRuntime/lib/Common/binary-to-decimal.cpp
+          ../../../FortranRuntime/lib/Common/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
+    ../../../FortranRuntime/lib/Common/binary-to-decimal.cpp
+    ../../../FortranRuntime/lib/Common/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
+          ../../../FortranRuntime/lib/Common/binary-to-decimal.cpp
+          ../../../FortranRuntime/lib/Common/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
+    ../../../FortranRuntime/lib/Common/binary-to-decimal.cpp
+    ../../../FortranRuntime/lib/Common/decimal-to-binary.cpp
   )
   add_dependencies(FortranDecimal FortranDecimal.static FortranDecimal.dynamic
     FortranDecimal.static_dbg FortranDecimal.dynamic_dbg)
diff --git a/flang/lib/Evaluate/call.cpp b/flang/lib/Evaluate/call.cpp
index c5b50e806d2497..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/Common/Fortran.h"
 #include "flang/Common/idioms.h"
 #include "flang/Evaluate/characteristics.h"
 #include "flang/Evaluate/check-expression.h"
 #include "flang/Evaluate/expression.h"
 #include "flang/Evaluate/tools.h"
 #include "flang/Semantics/symbol.h"
+#include "flang/Support/Fortran.h"
 
 namespace Fortran::evaluate {
 
diff --git a/flang/lib/Evaluate/characteristics.cpp b/flang/lib/Evaluate/characteristics.cpp
index 70e24d6e82eb8e..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/Common/indirection.h"
 #include "flang/Evaluate/check-expression.h"
 #include "flang/Evaluate/fold.h"
 #include "flang/Evaluate/intrinsics.h"
@@ -17,6 +16,7 @@
 #include "flang/Semantics/scope.h"
 #include "flang/Semantics/symbol.h"
 #include "flang/Semantics/tools.h"
+#include "flang/Support/indirection.h"
 #include "llvm/Support/raw_ostream.h"
 #include <initializer_list>
 
diff --git a/flang/lib/Evaluate/common.cpp b/flang/lib/Evaluate/common.cpp
index c633bff57b1ecd..ed040b0728c4db 100644
--- a/flang/lib/Evaluate/common.cpp
+++ b/flang/lib/Evaluate/common.cpp
@@ -11,8 +11,11 @@
 
 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..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/Common/indirection.h"
-#include "flang/Common/template.h"
-#include "flang/Common/unwrap.h"
 #include "flang/Evaluate/characteristics.h"
 #include "flang/Evaluate/common.h"
 #include "flang/Evaluate/constant.h"
@@ -31,6 +28,9 @@
 #include "flang/Semantics/scope.h"
 #include "flang/Semantics/symbol.h"
 #include "flang/Semantics/tools.h"
+#include "flang/Support/indirection.h"
+#include "flang/Support/template.h"
+#include "flang/Support/unwrap.h"
 #include <algorithm>
 #include <cmath>
 #include <complex>
diff --git a/flang/lib/Evaluate/formatting.cpp b/flang/lib/Evaluate/formatting.cpp
index 0870d56549f74d..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/Common/Fortran.h"
 #include "flang/Evaluate/call.h"
 #include "flang/Evaluate/constant.h"
 #include "flang/Evaluate/expression.h"
@@ -16,6 +15,7 @@
 #include "flang/Parser/characters.h"
 #include "flang/Semantics/semantics.h"
 #include "flang/Semantics/symbol.h"
+#include "flang/Support/Fortran.h"
 #include "llvm/Support/raw_ostream.h"
 
 namespace Fortran::evaluate {
diff --git a/flang/lib/Evaluate/intrinsics-library.cpp b/flang/lib/Evaluate/intrinsics-library.cpp
index ed28d8130808fa..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/Common/static-multimap-view.h"
 #include "flang/Evaluate/expression.h"
+#include "flang/Support/static-multimap-view.h"
 #include <cfloat>
 #include <cmath>
 #include <complex>
diff --git a/flang/lib/Evaluate/intrinsics.cpp b/flang/lib/Evaluate/intrinsics.cpp
index 166dae93178c51..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/Common/Fortran.h"
 #include "flang/Common/enum-set.h"
 #include "flang/Common/idioms.h"
 #include "flang/Evaluate/check-expression.h"
@@ -19,6 +18,7 @@
 #include "flang/Evaluate/type.h"
 #include "flang/Semantics/scope.h"
 #include "flang/Semantics/tools.h"
+#include "flang/Support/Fortran.h"
 #include "llvm/Support/raw_ostream.h"
 #include <algorithm>
 #include <cmath>
diff --git a/flang/lib/Evaluate/real.cpp b/flang/lib/Evaluate/real.cpp
index 642490646dcaf3..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/decimal.h"
 #include "flang/Common/idioms.h"
-#include "flang/Decimal/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..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/Common/template.h"
 #include "flang/Evaluate/characteristics.h"
 #include "flang/Evaluate/check-expression.h"
 #include "flang/Evaluate/fold.h"
@@ -17,6 +16,7 @@
 #include "flang/Evaluate/type.h"
 #include "flang/Parser/message.h"
 #include "flang/Semantics/symbol.h"
+#include "flang/Support/template.h"
 #include <functional>
 
 using namespace std::placeholders; // _1, _2, &c. for std::bind()
diff --git a/flang/lib/Evaluate/target.cpp b/flang/lib/Evaluate/target.cpp
index 1e2cf6b0d298d4..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/Common/template.h"
 #include "flang/Evaluate/common.h"
 #include "flang/Evaluate/type.h"
+#include "flang/Support/template.h"
 
 namespace Fortran::evaluate {
 
diff --git a/flang/lib/Frontend/CompilerInstance.cpp b/flang/lib/Frontend/CompilerInstance.cpp
index d37430e0e5773e..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/Common/Fortran-features.h"
 #include "flang/Frontend/CompilerInvocation.h"
 #include "flang/Frontend/TextDiagnosticPrinter.h"
 #include "flang/Parser/parsing.h"
 #include "flang/Parser/provenance.h"
 #include "flang/Semantics/semantics.h"
+#include "flang/Support/Fortran-features.h"
 #include "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 90c327546198b5..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/Common/Fortran-features.h"
-#include "flang/Common/OpenMP-features.h"
-#include "flang/Common/Version.h"
 #include "flang/Frontend/CodeGenOptions.h"
 #include "flang/Frontend/PreprocessorOptions.h"
 #include "flang/Frontend/TargetOptions.h"
 #include "flang/Semantics/semantics.h"
+#include "flang/Support/Fortran-features.h"
+#include "flang/Support/OpenMP-features.h"
+#include "flang/Support/Version.h"
 #include "flang/Tools/TargetSetup.h"
 #include "flang/Version.inc"
 #include "clang/Basic/AllDiagnostics.h"
diff --git a/flang/lib/Frontend/FrontendActions.cpp b/flang/lib/Frontend/FrontendActions.cpp
index cda82bcb7ecc71..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/Common/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 79e5a04463e00b..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/Common/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 c0ef96adc20c3e..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/Common/Fortran.h"
 #include "flang/Evaluate/fold.h"
 #include "flang/Lower/Bridge.h"
 #include "flang/Lower/Mangler.h"
@@ -23,6 +22,7 @@
 #include "flang/Optimizer/Support/Utils.h"
 #include "flang/Semantics/symbol.h"
 #include "flang/Semantics/tools.h"
+#include "flang/Support/Fortran.h"
 #include <optional>
 
 static mlir::FunctionType
diff --git a/flang/lib/Lower/ConvertExpr.cpp b/flang/lib/Lower/ConvertExpr.cpp
index 62a7615e1af13c..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/Common/default-kinds.h"
-#include "flang/Common/unwrap.h"
 #include "flang/Evaluate/fold.h"
 #include "flang/Evaluate/real.h"
 #include "flang/Evaluate/traverse.h"
@@ -52,6 +50,8 @@
 #include "flang/Semantics/symbol.h"
 #include "flang/Semantics/tools.h"
 #include "flang/Semantics/type.h"
+#include "flang/Support/default-kinds.h"
+#include "flang/Support/unwrap.h"
 #include "mlir/Dialect/Func/IR/FuncOps.h"
 #include "llvm/ADT/TypeSwitch.h"
 #include "llvm/Support/CommandLine.h"
diff --git a/flang/lib/Lower/Mangler.cpp b/flang/lib/Lower/Mangler.cpp
index a66dae8851a866..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/Common/reference.h"
 #include "flang/Lower/Support/Utils.h"
 #include "flang/Optimizer/Builder/Todo.h"
 #include "flang/Optimizer/Dialect/FIRType.h"
 #include "flang/Optimizer/Support/InternalNames.h"
 #include "flang/Semantics/tools.h"
+#include "flang/Support/reference.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringRef.h"
diff --git a/flang/lib/Optimizer/Builder/IntrinsicCall.cpp b/flang/lib/Optimizer/Builder/IntrinsicCall.cpp
index dc0dc47bda9a9d..b98ab3e6999655 100644
--- a/flang/lib/Optimizer/Builder/IntrinsicCall.cpp
+++ b/flang/lib/Optimizer/Builder/IntrinsicCall.cpp
@@ -14,7 +14,6 @@
 //===----------------------------------------------------------------------===//
 
 #include "flang/Optimizer/Builder/IntrinsicCall.h"
-#include "flang/Common/static-multimap-view.h"
 #include "flang/Optimizer/Builder/BoxValue.h"
 #include "flang/Optimizer/Builder/Character.h"
 #include "flang/Optimizer/Builder/Complex.h"
@@ -42,6 +41,7 @@
 #include "flang/Optimizer/Support/Utils.h"
 #include "flang/Runtime/entry-names.h"
 #include "flang/Runtime/iostat.h"
+#include "flang/Support/static-multimap-view.h"
 #include "mlir/Dialect/Complex/IR/Complex.h"
 #include "mlir/Dialect/LLVMIR/LLVMDialect.h"
 #include "mlir/Dialect/Math/IR/Math.h"
diff --git a/flang/lib/Optimizer/CodeGen/TypeConverter.cpp b/flang/lib/Optimizer/CodeGen/TypeConverter.cpp
index 1043494b6fb48a..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/Common/Fortran.h"
 #include "flang/Optimizer/Builder/Todo.h" // remove when TODO's are done
 #include "flang/Optimizer/CodeGen/DescriptorModel.h"
 #include "flang/Optimizer/CodeGen/TBAABuilder.h"
@@ -22,6 +21,7 @@
 #include "flang/Optimizer/Dialect/Support/FIRContext.h"
 #include "flang/Optimizer/Dialect/Support/KindMapping.h"
 #include "flang/Optimizer/Support/InternalNames.h"
+#include "flang/Support/Fortran.h"
 #include "mlir/Conversion/LLVMCommon/TypeConverter.h"
 #include "llvm/ADT/ScopeExit.h"
 #include "llvm/Support/Debug.h"
diff --git a/flang/lib/Optimizer/Dialect/FIRType.cpp b/flang/lib/Optimizer/Dialect/FIRType.cpp
index 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..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/Common/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 2c9c73e8a5394d..9fccbd24a74982 100644
--- a/flang/lib/Optimizer/Transforms/AssumedRankOpConversion.cpp
+++ b/flang/lib/Optimizer/Transforms/AssumedRankOpConversion.cpp
@@ -6,7 +6,6 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "flang/Common/Fortran.h"
 #include "flang/Lower/BuiltinModules.h"
 #include "flang/Optimizer/Builder/FIRBuilder.h"
 #include "flang/Optimizer/Builder/Runtime/Support.h"
@@ -17,6 +16,7 @@
 #include "flang/Optimizer/Support/Utils.h"
 #include "flang/Optimizer/Transforms/Passes.h"
 #include "flang/Runtime/support.h"
+#include "flang/Support/Fortran.h"
 #include "mlir/Dialect/Func/IR/FuncOps.h"
 #include "mlir/Pass/Pass.h"
 #include "mlir/Transforms/DialectConversion.h"
diff --git a/flang/lib/Optimizer/Transforms/CufOpConversion.cpp b/flang/lib/Optimizer/Transforms/CufOpConversion.cpp
index c22c74d3f78af7..d7d321c6b9af3f 100644
--- a/flang/lib/Optimizer/Transforms/CufOpConversion.cpp
+++ b/flang/lib/Optimizer/Transforms/CufOpConversion.cpp
@@ -6,7 +6,6 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "flang/Common/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 648628fd1c9af0..3e4f46297357f9 100644
--- a/flang/lib/Optimizer/Transforms/ExternalNameConversion.cpp
+++ b/flang/lib/Optimizer/Transforms/ExternalNameConversion.cpp
@@ -6,12 +6,12 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "flang/Common/Fortran.h"
 #include "flang/Optimizer/Dialect/FIRDialect.h"
 #include "flang/Optimizer/Dialect/FIROps.h"
 #include "flang/Optimizer/Dialect/FIROpsSupport.h"
 #include "flang/Optimizer/Support/InternalNames.h"
 #include "flang/Optimizer/Transforms/Passes.h"
+#include "flang/Support/Fortran.h"
 #include "mlir/IR/Attributes.h"
 #include "mlir/IR/SymbolTable.h"
 #include "mlir/Pass/Pass.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..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/Common/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 8a60a9e64f704b..eb088c30e94f20 100644
--- a/flang/lib/Optimizer/Transforms/StackReclaim.cpp
+++ b/flang/lib/Optimizer/Transforms/StackReclaim.cpp
@@ -6,10 +6,10 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "flang/Common/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/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/basic-parsers.h b/flang/lib/Parser/basic-parsers.h
index 515b5993d67376..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/Common/Fortran-features.h"
 #include "flang/Common/idioms.h"
-#include "flang/Common/indirection.h"
 #include "flang/Parser/char-block.h"
 #include "flang/Parser/message.h"
 #include "flang/Parser/parse-state.h"
 #include "flang/Parser/provenance.h"
 #include "flang/Parser/user-state.h"
+#include "flang/Support/Fortran-features.h"
+#include "flang/Support/indirection.h"
 #include <cstring>
 #include <functional>
 #include <list>
diff --git a/flang/lib/Parser/parse-tree.cpp b/flang/lib/Parser/parse-tree.cpp
index 7f0899aaa14294..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/Common/indirection.h"
 #include "flang/Parser/tools.h"
 #include "flang/Parser/user-state.h"
+#include "flang/Support/indirection.h"
 #include "llvm/Support/raw_ostream.h"
 #include <algorithm>
 
diff --git a/flang/lib/Parser/prescan.h b/flang/lib/Parser/prescan.h
index 9d4f7c0c302a1a..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/Common/Fortran-features.h"
 #include "flang/Parser/characters.h"
 #include "flang/Parser/message.h"
 #include "flang/Parser/provenance.h"
 #include "flang/Parser/token-sequence.h"
+#include "flang/Support/Fortran-features.h"
 #include <bitset>
 #include <optional>
 #include <string>
diff --git a/flang/lib/Parser/unparse.cpp b/flang/lib/Parser/unparse.cpp
index 2511a5dda9d095..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/Common/Fortran.h"
 #include "flang/Common/idioms.h"
-#include "flang/Common/indirection.h"
 #include "flang/Parser/characters.h"
 #include "flang/Parser/parse-tree-visitor.h"
 #include "flang/Parser/parse-tree.h"
 #include "flang/Parser/tools.h"
+#include "flang/Support/Fortran.h"
+#include "flang/Support/indirection.h"
 #include "llvm/Support/raw_ostream.h"
 #include <algorithm>
 #include <cinttypes>
diff --git a/flang/lib/Semantics/assignment.h b/flang/lib/Semantics/assignment.h
index 95d7b3cf91b17a..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/Common/indirection.h"
 #include "flang/Evaluate/expression.h"
 #include "flang/Semantics/semantics.h"
+#include "flang/Support/indirection.h"
 
 namespace Fortran::parser {
 class ContextualMessages;
diff --git a/flang/lib/Semantics/check-case.cpp b/flang/lib/Semantics/check-case.cpp
index d296460127e12c..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/Common/reference.h"
-#include "flang/Common/template.h"
 #include "flang/Evaluate/fold.h"
 #include "flang/Evaluate/type.h"
 #include "flang/Parser/parse-tree.h"
 #include "flang/Semantics/semantics.h"
 #include "flang/Semantics/tools.h"
+#include "flang/Support/reference.h"
+#include "flang/Support/template.h"
 #include <tuple>
 
 namespace Fortran::semantics {
diff --git a/flang/lib/Semantics/check-coarray.cpp b/flang/lib/Semantics/check-coarray.cpp
index 6cf61a6b923db3..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/Common/indirection.h"
 #include "flang/Evaluate/expression.h"
 #include "flang/Parser/message.h"
 #include "flang/Parser/parse-tree.h"
 #include "flang/Parser/tools.h"
 #include "flang/Semantics/expression.h"
 #include "flang/Semantics/tools.h"
+#include "flang/Support/indirection.h"
 
 namespace Fortran::semantics {
 
diff --git a/flang/lib/Semantics/check-cuda.cpp b/flang/lib/Semantics/check-cuda.cpp
index d8bd435bf09f38..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/Common/template.h"
 #include "flang/Evaluate/fold.h"
 #include "flang/Evaluate/tools.h"
 #include "flang/Evaluate/traverse.h"
@@ -17,6 +16,7 @@
 #include "flang/Semantics/expression.h"
 #include "flang/Semantics/symbol.h"
 #include "flang/Semantics/tools.h"
+#include "flang/Support/template.h"
 
 // Once labeled DO constructs have been canonicalized and their parse subtrees
 // transformed into parser::DoConstructs, scan the parser::Blocks of the program
diff --git a/flang/lib/Semantics/check-data.h b/flang/lib/Semantics/check-data.h
index 479d32568fa66a..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/Common/interval.h"
 #include "flang/Evaluate/fold-designator.h"
 #include "flang/Evaluate/initial-image.h"
 #include "flang/Semantics/expression.h"
 #include "flang/Semantics/semantics.h"
+#include "flang/Support/interval.h"
 #include <list>
 #include <map>
 #include <vector>
diff --git a/flang/lib/Semantics/check-do-forall.cpp b/flang/lib/Semantics/check-do-forall.cpp
index d798244ff1ef2d..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/Common/template.h"
 #include "flang/Evaluate/call.h"
 #include "flang/Evaluate/expression.h"
 #include "flang/Evaluate/tools.h"
@@ -22,6 +21,7 @@
 #include "flang/Semantics/symbol.h"
 #include "flang/Semantics/tools.h"
 #include "flang/Semantics/type.h"
+#include "flang/Support/template.h"
 
 namespace Fortran::evaluate {
 using ActualArgumentRef = common::Reference<const ActualArgument>;
diff --git a/flang/lib/Semantics/check-return.cpp b/flang/lib/Semantics/check-return.cpp
index ec2600bac3c68e..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/Common/Fortran-features.h"
 #include "flang/Parser/message.h"
 #include "flang/Parser/parse-tree.h"
 #include "flang/Semantics/semantics.h"
 #include "flang/Semantics/tools.h"
+#include "flang/Support/Fortran-features.h"
 
 namespace Fortran::semantics {
 
diff --git a/flang/lib/Semantics/check-select-rank.cpp b/flang/lib/Semantics/check-select-rank.cpp
index 2e602d307013c1..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/Common/Fortran.h"
 #include "flang/Common/idioms.h"
 #include "flang/Parser/message.h"
 #include "flang/Parser/tools.h"
 #include "flang/Semantics/tools.h"
+#include "flang/Support/Fortran.h"
 #include <list>
 #include <optional>
 #include <set>
diff --git a/flang/lib/Semantics/check-select-type.cpp b/flang/lib/Semantics/check-select-type.cpp
index 94d16a719277af..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/Common/reference.h"
 #include "flang/Evaluate/fold.h"
 #include "flang/Evaluate/type.h"
 #include "flang/Parser/parse-tree.h"
 #include "flang/Semantics/semantics.h"
 #include "flang/Semantics/tools.h"
+#include "flang/Support/reference.h"
 #include <optional>
 
 namespace Fortran::semantics {
diff --git a/flang/lib/Semantics/check-stop.cpp b/flang/lib/Semantics/check-stop.cpp
index 43535b07f029e9..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/Common/Fortran.h"
 #include "flang/Evaluate/expression.h"
 #include "flang/Parser/parse-tree.h"
 #include "flang/Semantics/semantics.h"
 #include "flang/Semantics/tools.h"
+#include "flang/Support/Fortran.h"
 #include <optional>
 
 namespace Fortran::semantics {
diff --git a/flang/lib/Semantics/data-to-inits.h b/flang/lib/Semantics/data-to-inits.h
index d8cc4601de26fa..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/Common/default-kinds.h"
-#include "flang/Common/interval.h"
 #include "flang/Evaluate/fold-designator.h"
 #include "flang/Evaluate/initial-image.h"
+#include "flang/Support/default-kinds.h"
+#include "flang/Support/interval.h"
 #include <list>
 #include <map>
 
diff --git a/flang/lib/Semantics/expression.cpp b/flang/lib/Semantics/expression.cpp
index 072ebe172f45a9..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/Common/Fortran.h"
 #include "flang/Common/idioms.h"
 #include "flang/Evaluate/common.h"
 #include "flang/Evaluate/fold.h"
@@ -24,6 +23,7 @@
 #include "flang/Semantics/semantics.h"
 #include "flang/Semantics/symbol.h"
 #include "flang/Semantics/tools.h"
+#include "flang/Support/Fortran.h"
 #include "llvm/Support/raw_ostream.h"
 #include <algorithm>
 #include <functional>
diff --git a/flang/lib/Semantics/pointer-assignment.cpp b/flang/lib/Semantics/pointer-assignment.cpp
index 4948fce77a2502..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/Common/template.h"
 #include "flang/Evaluate/characteristics.h"
 #include "flang/Evaluate/expression.h"
 #include "flang/Evaluate/fold.h"
@@ -21,6 +20,7 @@
 #include "flang/Semantics/expression.h"
 #include "flang/Semantics/symbol.h"
 #include "flang/Semantics/tools.h"
+#include "flang/Support/template.h"
 #include "llvm/Support/raw_ostream.h"
 #include <optional>
 #include <set>
diff --git a/flang/lib/Semantics/resolve-labels.cpp b/flang/lib/Semantics/resolve-labels.cpp
index e5e96ec6327e2b..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/Common/template.h"
 #include "flang/Parser/parse-tree-visitor.h"
 #include "flang/Semantics/semantics.h"
+#include "flang/Support/template.h"
 #include <cstdarg>
 #include <type_traits>
 
diff --git a/flang/lib/Semantics/resolve-names-utils.cpp b/flang/lib/Semantics/resolve-names-utils.cpp
index 39392257938d66..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/Common/Fortran-features.h"
-#include "flang/Common/Fortran.h"
 #include "flang/Common/idioms.h"
-#include "flang/Common/indirection.h"
 #include "flang/Evaluate/fold.h"
 #include "flang/Evaluate/tools.h"
 #include "flang/Evaluate/traverse.h"
@@ -20,6 +17,9 @@
 #include "flang/Semantics/expression.h"
 #include "flang/Semantics/semantics.h"
 #include "flang/Semantics/tools.h"
+#include "flang/Support/Fortran-features.h"
+#include "flang/Support/Fortran.h"
+#include "flang/Support/indirection.h"
 #include <initializer_list>
 #include <variant>
 
diff --git a/flang/lib/Semantics/resolve-names.cpp b/flang/lib/Semantics/resolve-names.cpp
index d8f601212d8d01..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/Common/Fortran.h"
-#include "flang/Common/default-kinds.h"
-#include "flang/Common/indirection.h"
 #include "flang/Common/restorer.h"
 #include "flang/Common/visit.h"
 #include "flang/Evaluate/characteristics.h"
@@ -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 b4fb72ce213017..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/Common/indirection.h"
 #include "flang/Parser/parse-tree-visitor.h"
 #include "flang/Parser/parse-tree.h"
 #include "flang/Parser/tools.h"
@@ -16,6 +15,7 @@
 #include "flang/Semantics/semantics.h"
 #include "flang/Semantics/symbol.h"
 #include "flang/Semantics/tools.h"
+#include "flang/Support/indirection.h"
 #include <list>
 
 namespace Fortran::semantics {
diff --git a/flang/lib/Semantics/semantics.cpp b/flang/lib/Semantics/semantics.cpp
index 8592d1e5d6217e..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/Common/default-kinds.h"
 #include "flang/Parser/parse-tree-visitor.h"
 #include "flang/Parser/tools.h"
 #include "flang/Semantics/expression.h"
 #include "flang/Semantics/scope.h"
 #include "flang/Semantics/symbol.h"
+#include "flang/Support/default-kinds.h"
 #include "llvm/Support/raw_ostream.h"
 #include "llvm/TargetParser/Host.h"
 #include "llvm/TargetParser/Triple.h"
diff --git a/flang/lib/Semantics/tools.cpp b/flang/lib/Semantics/tools.cpp
index 8d16ab71008766..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/Common/Fortran.h"
-#include "flang/Common/indirection.h"
 #include "flang/Parser/dump-parse-tree.h"
 #include "flang/Parser/message.h"
 #include "flang/Parser/parse-tree.h"
@@ -17,6 +15,8 @@
 #include "flang/Semantics/symbol.h"
 #include "flang/Semantics/tools.h"
 #include "flang/Semantics/type.h"
+#include "flang/Support/Fortran.h"
+#include "flang/Support/indirection.h"
 #include "llvm/Support/raw_ostream.h"
 #include <algorithm>
 #include <set>
diff --git a/flang/lib/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..868d18caa13c64 100644
--- a/flang/lib/Common/Fortran-features.cpp
+++ b/flang/lib/Support/Fortran-features.cpp
@@ -1,4 +1,4 @@
-//===-- lib/Common/Fortran-features.cpp -----------------------------------===//
+//===-- lib/Support/Fortran-features.cpp ------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -6,9 +6,9 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "flang/Common/Fortran-features.h"
-#include "flang/Common/Fortran.h"
+#include "flang/Support/Fortran-features.h"
 #include "flang/Common/idioms.h"
+#include "flang/Support/Fortran.h"
 
 namespace Fortran::common {
 
diff --git a/flang/lib/Common/Fortran.cpp b/flang/lib/Support/Fortran.cpp
similarity index 96%
rename from flang/lib/Common/Fortran.cpp
rename to flang/lib/Support/Fortran.cpp
index 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/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/test/lit.cfg.py b/flang/test/lit.cfg.py
index 4acbc0606d1977..228bbb7e313d82 100644
--- a/flang/test/lit.cfg.py
+++ b/flang/test/lit.cfg.py
@@ -169,7 +169,7 @@
 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")
+    include = os.path.join(config.flang_src_dir, "..", "FortranRuntime", "include")
 
     if (
         os.path.isfile(libruntime)
diff --git a/flang/tools/bbc/bbc.cpp b/flang/tools/bbc/bbc.cpp
index dcff4503f16571..917e052ef35fa1 100644
--- a/flang/tools/bbc/bbc.cpp
+++ b/flang/tools/bbc/bbc.cpp
@@ -14,10 +14,6 @@
 ///
 //===----------------------------------------------------------------------===//
 
-#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/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 3025dbd4dca4ab..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/Common/Fortran-features.h"
-#include "flang/Common/default-kinds.h"
 #include "flang/Parser/characters.h"
 #include "flang/Parser/dump-parse-tree.h"
 #include "flang/Parser/message.h"
@@ -31,6 +29,8 @@
 #include "flang/Parser/parsing.h"
 #include "flang/Parser/provenance.h"
 #include "flang/Parser/unparse.h"
+#include "flang/Support/Fortran-features.h"
+#include "flang/Support/default-kinds.h"
 #include "llvm/Support/Errno.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Program.h"
diff --git a/flang/tools/f18/CMakeLists.txt b/flang/tools/f18/CMakeLists.txt
index 9d7b8633958cb7..664c18f406c08c 100644
--- a/flang/tools/f18/CMakeLists.txt
+++ b/flang/tools/f18/CMakeLists.txt
@@ -105,10 +105,12 @@ if (NOT CMAKE_CROSSCOMPILING)
     set(compile_with "-fsyntax-only")
     set(object_output "")
     set(include_in_link FALSE)
+    set(fullpath "${FLANG_SOURCE_DIR}/../FortranRuntime/module/${filename}.f90")
     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)
+      set(fullpath "${FLANG_SOURCE_DIR}/../FortranRuntime/lib/Runtime/${filename}.f90")
     endif()
 
     set(base ${FLANG_INTRINSIC_MODULES_DIR}/${filename})
@@ -116,8 +118,8 @@ if (NOT CMAKE_CROSSCOMPILING)
     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}
+        ${fullpath}
+      DEPENDS flang-new ${fullpath} ${FLANG_SOURCE_DIR}/../FortranRuntime/module/__fortran_builtins.f90 ${depends}
     )
     list(APPEND MODULE_FILES ${base}.mod)
     install(FILES ${base}.mod DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/flang")
diff --git a/flang/unittests/CMakeLists.txt b/flang/unittests/CMakeLists.txt
index 945067fed4f82d..2d86e991aee610 100644
--- a/flang/unittests/CMakeLists.txt
+++ b/flang/unittests/CMakeLists.txt
@@ -72,8 +72,8 @@ function(add_flang_nongtest_unittest test_name)
 endfunction()
 
 add_subdirectory(Optimizer)
-add_subdirectory(Common)
-add_subdirectory(Decimal)
+add_subdirectory(../../FortranRuntime/unittests/Common Common)
+add_subdirectory(../../FortranRuntime/unittests/Decimal Decimal)
 add_subdirectory(Evaluate)
-add_subdirectory(Runtime)
+add_subdirectory(../../FortranRuntime/unittests/Runtime Runtime)
 add_subdirectory(Frontend)
diff --git a/flang/unittests/Evaluate/CMakeLists.txt b/flang/unittests/Evaluate/CMakeLists.txt
index 52eb385f4763fb..35bd7b0f18a90d 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/lib/Testing/testing.cpp
+  ../../../FortranRuntime/lib/Testing/fp-testing.cpp
 )
 set_target_properties(FortranEvaluateTesting PROPERTIES FOLDER "Flang/Tests")
 if (LLVM_LINK_LLVM_DYLIB)
@@ -69,23 +69,11 @@ add_flang_nongtest_unittest(real
 )
 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
   FortranEvaluate
   FortranSemantics
 )
+
+add_subdirectory(../../../FortranRuntime/unittests/Evaluate runtime)
\ No newline at end of file
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..d575f36def287e 100644
--- a/flang/unittests/Evaluate/expression.cpp
+++ b/flang/unittests/Evaluate/expression.cpp
@@ -1,10 +1,10 @@
 #include "flang/Evaluate/expression.h"
-#include "testing.h"
 #include "flang/Evaluate/fold.h"
 #include "flang/Evaluate/intrinsics.h"
 #include "flang/Evaluate/target.h"
 #include "flang/Evaluate/tools.h"
 #include "flang/Parser/message.h"
+#include "flang/Testing/testing.h"
 #include <cstdio>
 #include <cstdlib>
 #include <string>
diff --git a/flang/unittests/Evaluate/folding.cpp b/flang/unittests/Evaluate/folding.cpp
index 4e8ff9754e4ccb..832e55d44316da 100644
--- a/flang/unittests/Evaluate/folding.cpp
+++ b/flang/unittests/Evaluate/folding.cpp
@@ -1,4 +1,3 @@
-#include "testing.h"
 #include "../../lib/Evaluate/host.h"
 #include "flang/Evaluate/call.h"
 #include "flang/Evaluate/expression.h"
@@ -7,6 +6,7 @@
 #include "flang/Evaluate/intrinsics.h"
 #include "flang/Evaluate/target.h"
 #include "flang/Evaluate/tools.h"
+#include "flang/Testing/testing.h"
 #include <tuple>
 
 using namespace Fortran::evaluate;
diff --git a/flang/unittests/Evaluate/integer.cpp b/flang/unittests/Evaluate/integer.cpp
index 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..cca2f8c30247e0 100644
--- a/flang/unittests/Evaluate/intrinsics.cpp
+++ b/flang/unittests/Evaluate/intrinsics.cpp
@@ -1,10 +1,10 @@
 #include "flang/Evaluate/intrinsics.h"
-#include "testing.h"
 #include "flang/Evaluate/common.h"
 #include "flang/Evaluate/expression.h"
 #include "flang/Evaluate/target.h"
 #include "flang/Evaluate/tools.h"
 #include "flang/Parser/provenance.h"
+#include "flang/Testing/testing.h"
 #include "llvm/Support/raw_ostream.h"
 #include <initializer_list>
 #include <map>
diff --git a/flang/unittests/Evaluate/leading-zero-bit-count.cpp b/flang/unittests/Evaluate/leading-zero-bit-count.cpp
index 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..ba7d0d8d0c0e3a 100644
--- a/flang/unittests/Evaluate/logical.cpp
+++ b/flang/unittests/Evaluate/logical.cpp
@@ -1,5 +1,5 @@
-#include "testing.h"
 #include "flang/Evaluate/type.h"
+#include "flang/Testing/testing.h"
 #include <cstdio>
 
 template <int KIND> void testKind() {
diff --git a/flang/unittests/Evaluate/real.cpp b/flang/unittests/Evaluate/real.cpp
index ccbaf81f054cb5..23406fc6909aea 100644
--- a/flang/unittests/Evaluate/real.cpp
+++ b/flang/unittests/Evaluate/real.cpp
@@ -1,6 +1,6 @@
-#include "fp-testing.h"
-#include "testing.h"
 #include "flang/Evaluate/type.h"
+#include "flang/Testing/fp-testing.h"
+#include "flang/Testing/testing.h"
 #include "llvm/Support/raw_ostream.h"
 #include <cmath>
 #include <cstdio>
diff --git a/flang/unittests/Evaluate/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>
 



More information about the llvm-branch-commits mailing list