[flang-commits] [flang] [lld] [llvm] [Flang][DRAFT] LLVM_ENABLE_RUNTIMES=FortranRuntime (PR #110217)

Michael Kruse via flang-commits flang-commits at lists.llvm.org
Fri Sep 27 11:57:09 PDT 2024


https://github.com/Meinersbur updated https://github.com/llvm/llvm-project/pull/110217

>From f89c561fe1d11ead1172e576479ceff5b84fb8f7 Mon Sep 17 00:00:00 2001
From: Michael Kruse <llvm-project at meinersbur.de>
Date: Fri, 27 Sep 2024 09:18:49 +0200
Subject: [PATCH 1/6] [Flang] LLVM_ENABLE_RUNTIMES=FortranRuntime

Extract Flang's runtime library to use the LLVM_ENABLE_RUNTIME
mechanism.
---
 FortranRuntime/.clang-format                  |  21 +
 FortranRuntime/CMakeLists.txt                 | 184 ++++++++
 FortranRuntime/CODE_OWNERS.TXT                |  14 +
 FortranRuntime/LICENSE.TXT                    | 234 +++++++++++
 FortranRuntime/README.md                      |  20 +
 .../cmake/config.h.cmake.in                   |   0
 .../cmake/modules/AddFortranRuntime.cmake     | 109 +++++
 .../include/flang/Common/Fortran-consts.h     |  50 +++
 .../flang/Common}/ISO_Fortran_binding.h       |   5 +-
 .../Common}/ISO_Fortran_binding_wrapper.h     |   7 +-
 .../include/flang/Common/api-attrs.h          |   5 +-
 .../flang/Common}/binary-floating-point.h     |   2 +-
 .../flang/Common/bit-population-count.h       |   0
 .../include/flang/Common/constexpr-bitset.h   |   0
 .../include/flang/Common}/decimal.h           |   5 +-
 .../include/flang/Common/enum-class.h         |   0
 .../include/flang/Common/enum-set.h           |   0
 .../include/flang/Common/fast-int-set.h       |   2 +-
 .../include/flang/Common/float128.h           |   2 +-
 .../include/flang/Common/format.h             |   2 +-
 .../include/flang/Common/idioms.h             |   0
 .../flang/Common/leading-zero-bit-count.h     |   0
 .../include/flang/Common/optional.h           |   0
 .../include/flang/Common/real.h               |   0
 .../include/flang/Common/reference-wrapper.h  |   0
 .../include/flang/Common/restorer.h           |   0
 .../include/flang/Common/target-rounding.h    |  40 ++
 .../include/flang/Common/uint128.h            |   0
 .../include/flang/Common/variant.h            |   0
 .../include/flang/Common/visit.h              |   0
 .../include/flang/Common/windows-include.h    |   0
 .../include/flang/Runtime/CUDA/allocator.h    |   0
 .../include/flang/Runtime/CUDA/descriptor.h   |   0
 .../include/flang/Runtime/allocatable.h       |   0
 .../flang/Runtime/allocator-registry.h        |   2 +-
 .../include/flang/Runtime/array-constructor.h |   0
 .../include/flang/Runtime/assign.h            |   0
 .../include/flang/Runtime/c-or-cpp.h          |   0
 .../include/flang/Runtime/character.h         |   0
 .../include/flang/Runtime/command.h           |   0
 .../include/flang/Runtime/cpp-type.h          |   2 +-
 .../include/flang/Runtime/derived-api.h       |   0
 .../include/flang/Runtime/descriptor.h        |   2 +-
 .../include/flang/Runtime/entry-names.h       |   5 +-
 .../include/flang/Runtime/exceptions.h        |   2 +-
 .../include/flang/Runtime/execute.h           |   2 +-
 .../include/flang/Runtime/extensions.h        |   0
 .../flang/Runtime/freestanding-tools.h        |   0
 .../include/flang/Runtime/inquiry.h           |   2 +-
 .../include/flang/Runtime/io-api.h            |   0
 .../include/flang/Runtime/iostat.h            |   0
 .../include/flang/Runtime/magic-numbers.h     |   6 +-
 .../include/flang/Runtime/main.h              |   0
 .../flang/Runtime/matmul-instances.inc        |   0
 .../include/flang/Runtime/matmul-transpose.h  |   0
 .../include/flang/Runtime/matmul.h            |   0
 .../include/flang/Runtime/memory.h            |   0
 .../include/flang/Runtime/misc-intrinsic.h    |   0
 .../include/flang/Runtime/numeric.h           |   0
 .../include/flang/Runtime/pointer.h           |   0
 .../include/flang/Runtime/ragged.h            |   2 +-
 .../include/flang/Runtime/random.h            |   0
 .../include/flang/Runtime/reduce.h            |   0
 .../include/flang/Runtime/reduction.h         |   0
 .../include/flang/Runtime/stop.h              |   0
 .../include/flang/Runtime/support.h           |   2 +-
 .../include/flang/Runtime/temporary-stack.h   |   0
 .../include/flang/Runtime/time-intrinsic.h    |   0
 .../include/flang/Runtime/transformational.h  |   0
 .../include/flang/Runtime/type-code.h         |   4 +-
 .../include/flang/Testing}/fp-testing.h       |  14 +-
 .../include/flang/Testing}/testing.h          |   8 +
 FortranRuntime/lib/CMakeLists.txt             |  12 +
 .../lib/Common}/big-radix-floating-point.h    |   6 +-
 .../lib/Common}/binary-to-decimal.cpp         |   4 +-
 .../lib/Common}/decimal-to-binary.cpp         |   6 +-
 FortranRuntime/lib/Runtime/CMakeLists.txt     | 242 +++++++++++
 .../lib/Runtime}/CUDA/CMakeLists.txt          |   2 +-
 .../lib/Runtime}/CUDA/allocator.cpp           |   4 +-
 .../lib/Runtime}/CUDA/descriptor.cpp          |   2 +-
 .../lib/Runtime}/Float128Math/CMakeLists.txt  |   2 +-
 .../lib/Runtime}/Float128Math/acos.cpp        |   2 +-
 .../lib/Runtime}/Float128Math/acosh.cpp       |   2 +-
 .../lib/Runtime}/Float128Math/asin.cpp        |   2 +-
 .../lib/Runtime}/Float128Math/asinh.cpp       |   2 +-
 .../lib/Runtime}/Float128Math/atan.cpp        |   2 +-
 .../lib/Runtime}/Float128Math/atan2.cpp       |   2 +-
 .../lib/Runtime}/Float128Math/atanh.cpp       |   2 +-
 .../lib/Runtime}/Float128Math/ceil.cpp        |   2 +-
 .../lib/Runtime}/Float128Math/complex-math.c  |   5 +-
 .../lib/Runtime}/Float128Math/complex-math.h  |   2 +-
 .../lib/Runtime}/Float128Math/cos.cpp         |   2 +-
 .../lib/Runtime}/Float128Math/cosh.cpp        |   2 +-
 .../lib/Runtime}/Float128Math/erf.cpp         |   2 +-
 .../lib/Runtime}/Float128Math/erfc.cpp        |   2 +-
 .../lib/Runtime}/Float128Math/exp.cpp         |   2 +-
 .../lib/Runtime}/Float128Math/exponent.cpp    |   2 +-
 .../lib/Runtime}/Float128Math/floor.cpp       |   2 +-
 .../lib/Runtime}/Float128Math/fma.cpp         |   2 +-
 .../lib/Runtime}/Float128Math/fraction.cpp    |   2 +-
 .../lib/Runtime}/Float128Math/hypot.cpp       |   2 +-
 .../lib/Runtime}/Float128Math/j0.cpp          |   2 +-
 .../lib/Runtime}/Float128Math/j1.cpp          |   2 +-
 .../lib/Runtime}/Float128Math/jn.cpp          |   2 +-
 .../lib/Runtime}/Float128Math/lgamma.cpp      |   2 +-
 .../lib/Runtime}/Float128Math/llround.cpp     |   2 +-
 .../lib/Runtime}/Float128Math/log.cpp         |   2 +-
 .../lib/Runtime}/Float128Math/log10.cpp       |   2 +-
 .../lib/Runtime}/Float128Math/lround.cpp      |   2 +-
 .../lib/Runtime}/Float128Math/math-entries.h  |   2 +-
 .../lib/Runtime}/Float128Math/mod-real.cpp    |   2 +-
 .../lib/Runtime}/Float128Math/modulo-real.cpp |   2 +-
 .../lib/Runtime}/Float128Math/nearest.cpp     |   2 +-
 .../lib/Runtime}/Float128Math/norm2.cpp       |   2 +-
 .../Float128Math/numeric-template-specs.h     |   2 +-
 .../lib/Runtime}/Float128Math/pow.cpp         |   2 +-
 .../lib/Runtime}/Float128Math/random.cpp      |   2 +-
 .../lib/Runtime}/Float128Math/round.cpp       |   2 +-
 .../lib/Runtime}/Float128Math/rrspacing.cpp   |   2 +-
 .../lib/Runtime}/Float128Math/scale.cpp       |   2 +-
 .../Runtime}/Float128Math/set-exponent.cpp    |   2 +-
 .../lib/Runtime}/Float128Math/sin.cpp         |   2 +-
 .../lib/Runtime}/Float128Math/sinh.cpp        |   2 +-
 .../lib/Runtime}/Float128Math/spacing.cpp     |   2 +-
 .../lib/Runtime}/Float128Math/sqrt.cpp        |   2 +-
 .../lib/Runtime}/Float128Math/tan.cpp         |   2 +-
 .../lib/Runtime}/Float128Math/tanh.cpp        |   2 +-
 .../lib/Runtime}/Float128Math/tgamma.cpp      |   2 +-
 .../lib/Runtime}/Float128Math/trunc.cpp       |   2 +-
 .../lib/Runtime}/Float128Math/y0.cpp          |   2 +-
 .../lib/Runtime}/Float128Math/y1.cpp          |   2 +-
 .../lib/Runtime}/Float128Math/yn.cpp          |   2 +-
 .../lib/Runtime}/ISO_Fortran_binding.cpp      |   4 +-
 .../lib/Runtime}/ISO_Fortran_util.h           |   4 +-
 .../lib/Runtime}/allocatable.cpp              |   4 +-
 .../lib/Runtime}/allocator-registry.cpp       |   2 +-
 .../lib/Runtime}/array-constructor.cpp        |   2 +-
 .../lib/Runtime}/assign-impl.h                |   2 +-
 .../lib/Runtime}/assign.cpp                   |   2 +-
 .../lib/Runtime}/buffer.cpp                   |   2 +-
 .../lib/Runtime}/buffer.h                     |   2 +-
 .../lib/Runtime}/character.cpp                |   2 +-
 .../lib/Runtime}/command.cpp                  |   2 +-
 .../lib/Runtime}/complex-powi.cpp             |  15 +-
 .../lib/Runtime}/complex-reduction.c          |   5 +-
 .../lib/Runtime}/complex-reduction.h          |   5 +-
 .../lib/Runtime}/connection.cpp               |   2 +-
 .../lib/Runtime}/connection.h                 |   2 +-
 .../lib/Runtime}/copy.cpp                     |   2 +-
 .../lib/Runtime}/copy.h                       |   2 +-
 .../lib/Runtime}/derived-api.cpp              |   3 +-
 .../lib/Runtime}/derived.cpp                  |   2 +-
 .../lib/Runtime}/derived.h                    |   2 +-
 .../lib/Runtime}/descriptor-io.cpp            |   2 +-
 .../lib/Runtime}/descriptor-io.h              |   2 +-
 .../lib/Runtime}/descriptor.cpp               |   2 +-
 .../lib/Runtime}/dot-product.cpp              |   2 +-
 .../lib/Runtime}/edit-input.cpp               |   2 +-
 .../lib/Runtime}/edit-input.h                 |   4 +-
 .../lib/Runtime}/edit-output.cpp              |   2 +-
 .../lib/Runtime}/edit-output.h                |   4 +-
 .../lib/Runtime}/emit-encoded.h               |   2 +-
 .../lib/Runtime}/environment-default-list.h   |   5 +-
 .../lib/Runtime}/environment.cpp              |   2 +-
 .../lib/Runtime}/environment.h                |   4 +-
 .../lib/Runtime}/exceptions.cpp               |   2 +-
 .../lib/Runtime}/execute.cpp                  |   2 +-
 .../lib/Runtime}/extensions.cpp               |   2 +-
 .../lib/Runtime}/external-unit.cpp            |   2 +-
 .../lib/Runtime}/extrema.cpp                  |   2 +-
 .../lib/Runtime}/file.cpp                     |   2 +-
 .../lib/Runtime}/file.h                       |   2 +-
 .../lib/Runtime}/findloc.cpp                  |   2 +-
 .../lib/Runtime}/format-implementation.h      |   4 +-
 .../lib/Runtime}/format.cpp                   |   2 +-
 .../lib/Runtime}/format.h                     |   6 +-
 .../lib/Runtime}/inquiry.cpp                  |   2 +-
 .../lib/Runtime}/internal-unit.cpp            |   2 +-
 .../lib/Runtime}/internal-unit.h              |   2 +-
 .../lib/Runtime}/io-api-common.h              |   2 +-
 .../lib/Runtime}/io-api-minimal.cpp           |   2 +-
 .../lib/Runtime}/io-api.cpp                   |   2 +-
 .../lib/Runtime}/io-error.cpp                 |   2 +-
 .../lib/Runtime}/io-error.h                   |   2 +-
 .../lib/Runtime}/io-stmt.cpp                  |   2 +-
 .../lib/Runtime}/io-stmt.h                    |   2 +-
 .../lib/Runtime}/iostat.cpp                   |   2 +-
 .../lib/Runtime}/iso_fortran_env_impl.f90     |   2 +-
 .../lib/Runtime}/lock.h                       |   2 +-
 .../lib/Runtime}/main.cpp                     |   2 +-
 .../lib/Runtime}/matmul-transpose.cpp         |   2 +-
 .../lib/Runtime}/matmul.cpp                   |   2 +-
 .../lib/Runtime}/memory.cpp                   |   2 +-
 .../lib/Runtime}/misc-intrinsic.cpp           |   2 +-
 .../lib/Runtime}/namelist.cpp                 |   2 +-
 .../lib/Runtime}/namelist.h                   |   2 +-
 .../lib/Runtime}/non-tbp-dio.cpp              |   2 +-
 .../lib/Runtime}/non-tbp-dio.h                |   5 +-
 .../lib/Runtime}/numeric-templates.h          |   2 +-
 .../lib/Runtime}/numeric.cpp                  |   2 +-
 .../lib/Runtime}/pointer.cpp                  |   2 +-
 .../lib/Runtime}/product.cpp                  |   2 +-
 .../lib/Runtime}/pseudo-unit.cpp              |   2 +-
 .../lib/Runtime}/ragged.cpp                   |   2 +-
 .../lib/Runtime}/random-templates.h           |   2 +-
 .../lib/Runtime}/random.cpp                   |   2 +-
 .../lib/Runtime}/reduce.cpp                   |   2 +-
 .../lib/Runtime}/reduction-templates.h        |   2 +-
 .../lib/Runtime}/reduction.cpp                |   2 +-
 .../lib/Runtime}/stack.h                      |   2 +-
 .../lib/Runtime}/stat.cpp                     |   2 +-
 .../lib/Runtime}/stat.h                       |   4 +-
 .../lib/Runtime}/stop.cpp                     |   2 +-
 .../lib/Runtime}/sum.cpp                      |   2 +-
 .../lib/Runtime}/support.cpp                  |   2 +-
 .../lib/Runtime}/temporary-stack.cpp          |   4 +-
 .../lib/Runtime}/terminator.cpp               |   2 +-
 .../lib/Runtime}/terminator.h                 |   2 +-
 .../lib/Runtime}/time-intrinsic.cpp           |   2 +-
 .../lib/Runtime}/tools.cpp                    |   2 +-
 .../lib/Runtime}/tools.h                      |   2 +-
 .../lib/Runtime}/transformational.cpp         |   2 +-
 .../lib/Runtime}/type-code.cpp                |   3 +-
 .../lib/Runtime}/type-info.cpp                |   2 +-
 .../lib/Runtime}/type-info.h                  |   4 +-
 .../lib/Runtime}/unit-map.cpp                 |   2 +-
 .../lib/Runtime}/unit-map.h                   |   2 +-
 .../lib/Runtime}/unit.cpp                     |   2 +-
 .../lib/Runtime}/unit.h                       |   2 +-
 .../lib/Runtime}/utf.cpp                      |   2 +-
 .../lib/Runtime}/utf.h                        |   2 +-
 FortranRuntime/lib/Testing/CMakeLists.txt     |  19 +
 .../lib/Testing}/fp-testing.cpp               |  12 +-
 .../lib/Testing}/testing.cpp                  |  10 +-
 .../module/.clang-format                      |   0
 FortranRuntime/module/CMakeLists.txt          |  63 +++
 .../module/__cuda_builtins.f90                |   0
 .../module/__fortran_builtins.f90             |   0
 .../module/__fortran_ieee_exceptions.f90      |   0
 .../module/__fortran_type_info.f90            |   0
 .../module/__ppc_intrinsics.f90               |   0
 .../module/__ppc_types.f90                    |   0
 .../module/cudadevice.f90                     |   2 +-
 .../module/ieee_arithmetic.f90                |   0
 .../module/ieee_exceptions.f90                |   0
 .../module/ieee_features.f90                  |   0
 .../module/iso_c_binding.f90                  |   0
 .../module/iso_fortran_env.f90                |   0
 {flang => FortranRuntime}/module/mma.f90      |  43 +-
 FortranRuntime/test/CMakeLists.txt            |  70 ++++
 FortranRuntime/test/NonGtestUnit/lit.cfg.py   |  21 +
 .../test/NonGtestUnit/lit.site.cfg.py.in      |  13 +
 .../test/Runtime/no-cpp-dep.c                 |  12 +-
 FortranRuntime/test/Unit/lit.cfg.py           |  21 +
 FortranRuntime/test/Unit/lit.site.cfg.py.in   |  14 +
 FortranRuntime/test/lit.cfg.py                |  78 ++++
 FortranRuntime/test/lit.site.cfg.py.in        |  17 +
 FortranRuntime/unittests/CMakeLists.txt       |  62 +++
 .../unittests/Common/CMakeLists.txt           |  13 +
 .../unittests/Common/FastIntSetTest.cpp       |   2 +-
 .../unittests/Decimal/CMakeLists.txt          |  20 +
 .../unittests/Decimal/quick-sanity-test.cpp   |  10 +-
 .../unittests/Decimal/thorough-test.cpp       |  10 +-
 .../unittests/Evaluate/CMakeLists.txt         |  19 +
 .../Evaluate/ISO-Fortran-binding.cpp          |  12 +-
 .../unittests/Evaluate/reshape.cpp            |  10 +-
 .../unittests/Runtime/AccessTest.cpp          |   2 +-
 .../unittests/Runtime/Allocatable.cpp         |   2 +-
 .../unittests/Runtime/ArrayConstructor.cpp    |   2 +-
 .../unittests/Runtime/BufferTest.cpp          |   4 +-
 .../unittests/Runtime/CMakeLists.txt          |  19 +-
 .../unittests/Runtime/CUDA/AllocatorCUF.cpp   |   4 +-
 .../unittests/Runtime/CharacterTest.cpp       |   2 +-
 .../unittests/Runtime/CommandTest.cpp         |   2 +-
 .../unittests/Runtime/Complex.cpp             |   4 +-
 .../unittests/Runtime/CrashHandlerFixture.cpp |   4 +-
 .../unittests/Runtime/CrashHandlerFixture.h   |   2 +-
 .../unittests/Runtime/Derived.cpp             |   2 +-
 .../unittests/Runtime/ExternalIOTest.cpp      |   2 +-
 .../unittests/Runtime/Format.cpp              |   8 +-
 .../unittests/Runtime/Inquiry.cpp             |   2 +-
 .../unittests/Runtime/ListInputTest.cpp       |   4 +-
 .../unittests/Runtime/LogicalFormatTest.cpp   |   2 +-
 .../unittests/Runtime/Matmul.cpp              |   2 +-
 .../unittests/Runtime/MatmulTranspose.cpp     |   2 +-
 .../unittests/Runtime/MiscIntrinsic.cpp       |   2 +-
 .../unittests/Runtime/Namelist.cpp            |   4 +-
 .../unittests/Runtime/Numeric.cpp             |   2 +-
 .../unittests/Runtime/NumericalFormatTest.cpp |   2 +-
 .../unittests/Runtime/Pointer.cpp             |   2 +-
 .../unittests/Runtime/Ragged.cpp              |   2 +-
 .../unittests/Runtime/Random.cpp              |   2 +-
 .../unittests/Runtime/Reduction.cpp           |   2 +-
 .../unittests/Runtime/RuntimeCrashTest.cpp    |   4 +-
 .../unittests/Runtime/Stop.cpp                |   4 +-
 .../unittests/Runtime/Support.cpp             |   2 +-
 .../unittests/Runtime/TemporaryStack.cpp      |   4 +-
 .../unittests/Runtime/Time.cpp                |   2 +-
 .../unittests/Runtime/Transformational.cpp    |   2 +-
 .../unittests/Runtime/tools.h                 |   2 +-
 clang/lib/Driver/ToolChains/CommonArgs.cpp    |   3 +-
 clang/lib/Driver/ToolChains/Flang.cpp         |   4 -
 flang/CMakeLists.txt                          |  45 +-
 flang/docs/FlangDriver.md                     |   5 +-
 flang/include/flang/Evaluate/call.h           |   6 +-
 .../include/flang/Evaluate/characteristics.h  |   6 +-
 flang/include/flang/Evaluate/common.h         |  18 +-
 flang/include/flang/Evaluate/constant.h       |   4 +-
 flang/include/flang/Evaluate/expression.h     |   6 +-
 flang/include/flang/Evaluate/formatting.h     |   2 +-
 flang/include/flang/Evaluate/intrinsics.h     |   2 +-
 flang/include/flang/Evaluate/shape.h          |   2 +-
 flang/include/flang/Evaluate/target.h         |  17 +-
 flang/include/flang/Evaluate/tools.h          |   4 +-
 flang/include/flang/Evaluate/traverse.h       |   2 +-
 flang/include/flang/Evaluate/type.h           |   6 +-
 flang/include/flang/Evaluate/variable.h       |   4 +-
 .../include/flang/Frontend/FrontendOptions.h  |   2 +-
 flang/include/flang/Lower/AbstractConverter.h |   2 +-
 flang/include/flang/Lower/Bridge.h            |   2 +-
 flang/include/flang/Lower/CallInterface.h     |   2 +-
 flang/include/flang/Lower/ConvertType.h       |   2 +-
 flang/include/flang/Lower/LoweringOptions.h   |   2 +-
 flang/include/flang/Lower/PFTBuilder.h        |   4 +-
 flang/include/flang/Lower/Support/Utils.h     |   2 +-
 flang/include/flang/Lower/SymbolMap.h         |   2 +-
 .../flang/Optimizer/Builder/FIRBuilder.h      |   2 +-
 .../flang/Optimizer/Builder/IntrinsicCall.h   |   1 +
 .../Optimizer/Builder/PPCIntrinsicCall.h      |   2 +-
 .../Optimizer/Builder/Runtime/RTBuilder.h     |   2 +-
 .../flang/Optimizer/CodeGen/DescriptorModel.h |   2 +-
 .../Dialect/CUF/Attributes/CUFAttr.h          |   2 +-
 .../flang/Optimizer/Support/TypeCode.h        |   2 +-
 flang/include/flang/Optimizer/Support/Utils.h |   2 +-
 flang/include/flang/Parser/char-block.h       |   2 +-
 flang/include/flang/Parser/dump-parse-tree.h  |   4 +-
 flang/include/flang/Parser/message.h          |   2 +-
 flang/include/flang/Parser/parse-state.h      |   2 +-
 flang/include/flang/Parser/parse-tree.h       |   4 +-
 flang/include/flang/Parser/parsing.h          |   2 +-
 flang/include/flang/Parser/provenance.h       |   2 +-
 flang/include/flang/Parser/source.h           |   2 +-
 flang/include/flang/Parser/user-state.h       |   2 +-
 flang/include/flang/Semantics/expression.h    |   4 +-
 .../flang/Semantics/runtime-type-info.h       |   2 +-
 flang/include/flang/Semantics/scope.h         |   4 +-
 flang/include/flang/Semantics/semantics.h     |   2 +-
 flang/include/flang/Semantics/symbol.h        |   4 +-
 flang/include/flang/Semantics/tools.h         |   2 +-
 flang/include/flang/Semantics/type.h          |   2 +-
 .../{Common => Support}/Fortran-features.h    |   4 +-
 .../flang/{Common => Support}/Fortran.h       |  38 +-
 .../{Common => Support}/MathOptionsBase.def   |   0
 .../{Common => Support}/MathOptionsBase.h     |   8 +-
 .../{Common => Support}/OpenMP-features.h     |   2 +-
 .../flang/{Common => Support}/Version.h       |   2 +-
 .../flang/{Common => Support}/default-kinds.h |   4 +-
 .../flang/{Common => Support}/indirection.h   |   4 +-
 .../flang/{Common => Support}/interval.h      |   4 +-
 .../{Common => Support}/reference-counted.h   |   2 +-
 .../flang/{Common => Support}/reference.h     |   2 +-
 .../static-multimap-view.h                    |   2 +-
 .../flang/{Common => Support}/template.h      |   4 +-
 .../flang/{Common => Support}/unwrap.h        |   6 +-
 flang/include/flang/Tools/CrossToolHelpers.h  |   2 +-
 flang/lib/CMakeLists.txt                      |   5 +-
 flang/lib/Common/CMakeLists.txt               |  60 +--
 flang/lib/Decimal/CMakeLists.txt              |  86 ----
 flang/lib/Evaluate/CMakeLists.txt             |   3 +-
 flang/lib/Evaluate/call.cpp                   |   2 +-
 flang/lib/Evaluate/characteristics.cpp        |   2 +-
 flang/lib/Evaluate/common.cpp                 |   4 +
 flang/lib/Evaluate/fold-implementation.h      |   6 +-
 flang/lib/Evaluate/formatting.cpp             |   2 +-
 flang/lib/Evaluate/intrinsics-library.cpp     |   2 +-
 flang/lib/Evaluate/intrinsics.cpp             |   2 +-
 flang/lib/Evaluate/real.cpp                   |   2 +-
 flang/lib/Evaluate/shape.cpp                  |   2 +-
 flang/lib/Evaluate/target.cpp                 |   2 +-
 flang/lib/Frontend/CMakeLists.txt             |   2 +-
 flang/lib/Frontend/CompilerInstance.cpp       |   2 +-
 flang/lib/Frontend/CompilerInvocation.cpp     |   6 +-
 flang/lib/Frontend/FrontendActions.cpp        |   2 +-
 flang/lib/Lower/Bridge.cpp                    |   2 +-
 flang/lib/Lower/CMakeLists.txt                |   2 +-
 flang/lib/Lower/CallInterface.cpp             |   2 +-
 flang/lib/Lower/ConvertExpr.cpp               |   4 +-
 flang/lib/Lower/Mangler.cpp                   |   2 +-
 flang/lib/Optimizer/Builder/IntrinsicCall.cpp |  21 +-
 flang/lib/Optimizer/CodeGen/TypeConverter.cpp |   2 +-
 flang/lib/Optimizer/Dialect/FIRType.cpp       |   2 +-
 .../lib/Optimizer/Transforms/AddDebugInfo.cpp |   2 +-
 .../Transforms/AssumedRankOpConversion.cpp    |   2 +-
 flang/lib/Optimizer/Transforms/CMakeLists.txt |   1 +
 .../Optimizer/Transforms/CufOpConversion.cpp  |   2 +-
 .../Transforms/ExternalNameConversion.cpp     |   2 +-
 .../Optimizer/Transforms/LoopVersioning.cpp   |   2 +-
 .../Transforms/SimplifyIntrinsics.cpp         |   2 +-
 .../lib/Optimizer/Transforms/StackReclaim.cpp |   2 +-
 flang/lib/Optimizer/Transforms/VScaleAttr.cpp |   2 +-
 flang/lib/Parser/CMakeLists.txt               |   2 +-
 flang/lib/Parser/basic-parsers.h              |   4 +-
 flang/lib/Parser/parse-tree.cpp               |   2 +-
 flang/lib/Parser/prescan.h                    |   2 +-
 flang/lib/Parser/unparse.cpp                  |   4 +-
 flang/lib/Semantics/CMakeLists.txt            |   2 +-
 flang/lib/Semantics/assignment.h              |   2 +-
 flang/lib/Semantics/check-case.cpp            |   4 +-
 flang/lib/Semantics/check-coarray.cpp         |   2 +-
 flang/lib/Semantics/check-cuda.cpp            |   2 +-
 flang/lib/Semantics/check-data.h              |   2 +-
 flang/lib/Semantics/check-do-forall.cpp       |   2 +-
 flang/lib/Semantics/check-return.cpp          |   2 +-
 flang/lib/Semantics/check-select-rank.cpp     |   2 +-
 flang/lib/Semantics/check-select-type.cpp     |   2 +-
 flang/lib/Semantics/check-stop.cpp            |   2 +-
 flang/lib/Semantics/data-to-inits.h           |   4 +-
 flang/lib/Semantics/expression.cpp            |   2 +-
 flang/lib/Semantics/pointer-assignment.cpp    |   2 +-
 flang/lib/Semantics/resolve-labels.cpp        |   2 +-
 flang/lib/Semantics/resolve-names-utils.cpp   |   6 +-
 flang/lib/Semantics/resolve-names.cpp         |   6 +-
 flang/lib/Semantics/rewrite-parse-tree.cpp    |   2 +-
 flang/lib/Semantics/semantics.cpp             |   2 +-
 flang/lib/Semantics/tools.cpp                 |   4 +-
 flang/lib/Support/CMakeLists.txt              |  56 +++
 .../{Common => Support}/Fortran-features.cpp  |   6 +-
 flang/lib/{Common => Support}/Fortran.cpp     |   6 +-
 flang/lib/{Common => Support}/Version.cpp     |   4 +-
 flang/lib/Support/big-radix-floating-point.h  | 396 ++++++++++++++++++
 .../lib/{Common => Support}/default-kinds.cpp |   4 +-
 flang/lib/{Common => Support}/idioms.cpp      |   2 +-
 flang/runtime/CMakeLists.txt                  | 314 --------------
 flang/test/CMakeLists.txt                     |   4 +-
 flang/test/Driver/linker-flags.f90            |   6 +-
 .../test/Driver/msvc-dependent-lib-flags.f90  |   4 -
 flang/test/lib/CMakeLists.txt                 |   1 +
 flang/test/lit.cfg.py                         |  23 -
 flang/test/lit.site.cfg.py.in                 |   1 -
 flang/tools/CMakeLists.txt                    |   1 -
 flang/tools/bbc/CMakeLists.txt                |   1 +
 flang/tools/bbc/bbc.cpp                       |   8 +-
 flang/tools/f18-parse-demo/CMakeLists.txt     |   2 +
 flang/tools/f18-parse-demo/f18-parse-demo.cpp |   4 +-
 flang/tools/f18/CMakeLists.txt                | 173 --------
 flang/tools/f18/dump.cpp                      |  42 --
 flang/tools/fir-opt/CMakeLists.txt            |   2 +
 flang/tools/flang-driver/CMakeLists.txt       |   3 +
 flang/tools/tco/CMakeLists.txt                |   2 +
 flang/unittests/CMakeLists.txt                |  37 --
 flang/unittests/Common/CMakeLists.txt         |   3 -
 flang/unittests/Decimal/CMakeLists.txt        |  10 -
 flang/unittests/Evaluate/CMakeLists.txt       |  24 +-
 .../Evaluate/bit-population-count.cpp         |   2 +-
 flang/unittests/Evaluate/expression.cpp       |   2 +-
 flang/unittests/Evaluate/folding.cpp          |   2 +-
 flang/unittests/Evaluate/integer.cpp          |   2 +-
 flang/unittests/Evaluate/intrinsics.cpp       |   2 +-
 .../Evaluate/leading-zero-bit-count.cpp       |   2 +-
 flang/unittests/Evaluate/logical.cpp          |   2 +-
 flang/unittests/Evaluate/real.cpp             |   4 +-
 flang/unittests/Evaluate/uint128.cpp          |   2 +-
 flang/unittests/Runtime/CUDA/CMakeLists.txt   |  15 -
 lld/COFF/MinGW.cpp                            |   6 +-
 llvm/CMakeLists.txt                           |   2 +-
 .../modules/LLVMExternalProjectUtils.cmake    |  16 +-
 llvm/projects/CMakeLists.txt                  |   5 +-
 llvm/runtimes/CMakeLists.txt                  |  32 +-
 runtimes/CMakeLists.txt                       |   3 +-
 469 files changed, 2512 insertions(+), 1388 deletions(-)
 create mode 100644 FortranRuntime/.clang-format
 create mode 100644 FortranRuntime/CMakeLists.txt
 create mode 100644 FortranRuntime/CODE_OWNERS.TXT
 create mode 100644 FortranRuntime/LICENSE.TXT
 create mode 100644 FortranRuntime/README.md
 rename flang/runtime/config.h.cmake => FortranRuntime/cmake/config.h.cmake.in (100%)
 create mode 100644 FortranRuntime/cmake/modules/AddFortranRuntime.cmake
 create mode 100644 FortranRuntime/include/flang/Common/Fortran-consts.h
 rename {flang/include/flang => FortranRuntime/include/flang/Common}/ISO_Fortran_binding.h (97%)
 rename {flang/include/flang => FortranRuntime/include/flang/Common}/ISO_Fortran_binding_wrapper.h (85%)
 rename {flang => FortranRuntime}/include/flang/Common/api-attrs.h (99%)
 rename {flang/include/flang/Decimal => FortranRuntime/include/flang/Common}/binary-floating-point.h (99%)
 rename {flang => FortranRuntime}/include/flang/Common/bit-population-count.h (100%)
 rename {flang => FortranRuntime}/include/flang/Common/constexpr-bitset.h (100%)
 rename {flang/include/flang/Decimal => FortranRuntime/include/flang/Common}/decimal.h (97%)
 rename {flang => FortranRuntime}/include/flang/Common/enum-class.h (100%)
 rename {flang => FortranRuntime}/include/flang/Common/enum-set.h (100%)
 rename {flang => FortranRuntime}/include/flang/Common/fast-int-set.h (99%)
 rename {flang => FortranRuntime}/include/flang/Common/float128.h (96%)
 rename {flang => FortranRuntime}/include/flang/Common/format.h (99%)
 rename {flang => FortranRuntime}/include/flang/Common/idioms.h (100%)
 rename {flang => FortranRuntime}/include/flang/Common/leading-zero-bit-count.h (100%)
 rename {flang => FortranRuntime}/include/flang/Common/optional.h (100%)
 rename {flang => FortranRuntime}/include/flang/Common/real.h (100%)
 rename {flang => FortranRuntime}/include/flang/Common/reference-wrapper.h (100%)
 rename {flang => FortranRuntime}/include/flang/Common/restorer.h (100%)
 create mode 100644 FortranRuntime/include/flang/Common/target-rounding.h
 rename {flang => FortranRuntime}/include/flang/Common/uint128.h (100%)
 rename {flang => FortranRuntime}/include/flang/Common/variant.h (100%)
 rename {flang => FortranRuntime}/include/flang/Common/visit.h (100%)
 rename {flang => FortranRuntime}/include/flang/Common/windows-include.h (100%)
 rename {flang => FortranRuntime}/include/flang/Runtime/CUDA/allocator.h (100%)
 rename {flang => FortranRuntime}/include/flang/Runtime/CUDA/descriptor.h (100%)
 rename {flang => FortranRuntime}/include/flang/Runtime/allocatable.h (100%)
 rename {flang => FortranRuntime}/include/flang/Runtime/allocator-registry.h (96%)
 rename {flang => FortranRuntime}/include/flang/Runtime/array-constructor.h (100%)
 rename {flang => FortranRuntime}/include/flang/Runtime/assign.h (100%)
 rename {flang => FortranRuntime}/include/flang/Runtime/c-or-cpp.h (100%)
 rename {flang => FortranRuntime}/include/flang/Runtime/character.h (100%)
 rename {flang => FortranRuntime}/include/flang/Runtime/command.h (100%)
 rename {flang => FortranRuntime}/include/flang/Runtime/cpp-type.h (98%)
 rename {flang => FortranRuntime}/include/flang/Runtime/derived-api.h (100%)
 rename {flang => FortranRuntime}/include/flang/Runtime/descriptor.h (99%)
 rename {flang => FortranRuntime}/include/flang/Runtime/entry-names.h (97%)
 rename {flang => FortranRuntime}/include/flang/Runtime/exceptions.h (91%)
 rename {flang => FortranRuntime}/include/flang/Runtime/execute.h (93%)
 rename {flang => FortranRuntime}/include/flang/Runtime/extensions.h (100%)
 rename {flang => FortranRuntime}/include/flang/Runtime/freestanding-tools.h (100%)
 rename {flang => FortranRuntime}/include/flang/Runtime/inquiry.h (94%)
 rename {flang => FortranRuntime}/include/flang/Runtime/io-api.h (100%)
 rename {flang => FortranRuntime}/include/flang/Runtime/iostat.h (100%)
 rename {flang => FortranRuntime}/include/flang/Runtime/magic-numbers.h (98%)
 rename {flang => FortranRuntime}/include/flang/Runtime/main.h (100%)
 rename {flang => FortranRuntime}/include/flang/Runtime/matmul-instances.inc (100%)
 rename {flang => FortranRuntime}/include/flang/Runtime/matmul-transpose.h (100%)
 rename {flang => FortranRuntime}/include/flang/Runtime/matmul.h (100%)
 rename {flang => FortranRuntime}/include/flang/Runtime/memory.h (100%)
 rename {flang => FortranRuntime}/include/flang/Runtime/misc-intrinsic.h (100%)
 rename {flang => FortranRuntime}/include/flang/Runtime/numeric.h (100%)
 rename {flang => FortranRuntime}/include/flang/Runtime/pointer.h (100%)
 rename {flang => FortranRuntime}/include/flang/Runtime/ragged.h (97%)
 rename {flang => FortranRuntime}/include/flang/Runtime/random.h (100%)
 rename {flang => FortranRuntime}/include/flang/Runtime/reduce.h (100%)
 rename {flang => FortranRuntime}/include/flang/Runtime/reduction.h (100%)
 rename {flang => FortranRuntime}/include/flang/Runtime/stop.h (100%)
 rename {flang => FortranRuntime}/include/flang/Runtime/support.h (96%)
 rename {flang => FortranRuntime}/include/flang/Runtime/temporary-stack.h (100%)
 rename {flang => FortranRuntime}/include/flang/Runtime/time-intrinsic.h (100%)
 rename {flang => FortranRuntime}/include/flang/Runtime/transformational.h (100%)
 rename {flang => FortranRuntime}/include/flang/Runtime/type-code.h (96%)
 rename {flang/unittests/Evaluate => FortranRuntime/include/flang/Testing}/fp-testing.h (56%)
 rename {flang/unittests/Evaluate => FortranRuntime/include/flang/Testing}/testing.h (80%)
 create mode 100644 FortranRuntime/lib/CMakeLists.txt
 rename {flang/lib/Decimal => FortranRuntime/lib/Common}/big-radix-floating-point.h (98%)
 rename {flang/lib/Decimal => FortranRuntime/lib/Common}/binary-to-decimal.cpp (99%)
 rename {flang/lib/Decimal => FortranRuntime/lib/Common}/decimal-to-binary.cpp (99%)
 create mode 100644 FortranRuntime/lib/Runtime/CMakeLists.txt
 rename {flang/runtime => FortranRuntime/lib/Runtime}/CUDA/CMakeLists.txt (93%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/CUDA/allocator.cpp (94%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/CUDA/descriptor.cpp (91%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/Float128Math/CMakeLists.txt (98%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/Float128Math/acos.cpp (87%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/Float128Math/acosh.cpp (87%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/Float128Math/asin.cpp (87%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/Float128Math/asinh.cpp (87%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/Float128Math/atan.cpp (87%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/Float128Math/atan2.cpp (88%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/Float128Math/atanh.cpp (87%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/Float128Math/ceil.cpp (87%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/Float128Math/complex-math.c (92%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/Float128Math/complex-math.h (96%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/Float128Math/cos.cpp (87%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/Float128Math/cosh.cpp (87%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/Float128Math/erf.cpp (87%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/Float128Math/erfc.cpp (87%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/Float128Math/exp.cpp (87%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/Float128Math/exponent.cpp (90%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/Float128Math/floor.cpp (87%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/Float128Math/fma.cpp (89%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/Float128Math/fraction.cpp (87%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/Float128Math/hypot.cpp (88%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/Float128Math/j0.cpp (87%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/Float128Math/j1.cpp (87%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/Float128Math/jn.cpp (87%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/Float128Math/lgamma.cpp (87%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/Float128Math/llround.cpp (88%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/Float128Math/log.cpp (87%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/Float128Math/log10.cpp (87%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/Float128Math/lround.cpp (87%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/Float128Math/math-entries.h (99%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/Float128Math/mod-real.cpp (89%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/Float128Math/modulo-real.cpp (89%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/Float128Math/nearest.cpp (89%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/Float128Math/norm2.cpp (93%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/Float128Math/numeric-template-specs.h (96%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/Float128Math/pow.cpp (88%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/Float128Math/random.cpp (89%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/Float128Math/round.cpp (89%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/Float128Math/rrspacing.cpp (87%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/Float128Math/scale.cpp (90%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/Float128Math/set-exponent.cpp (88%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/Float128Math/sin.cpp (87%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/Float128Math/sinh.cpp (87%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/Float128Math/spacing.cpp (87%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/Float128Math/sqrt.cpp (87%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/Float128Math/tan.cpp (87%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/Float128Math/tanh.cpp (87%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/Float128Math/tgamma.cpp (87%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/Float128Math/trunc.cpp (89%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/Float128Math/y0.cpp (87%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/Float128Math/y1.cpp (87%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/Float128Math/yn.cpp (87%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/ISO_Fortran_binding.cpp (98%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/ISO_Fortran_util.h (96%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/allocatable.cpp (98%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/allocator-registry.cpp (94%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/array-constructor.cpp (99%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/assign-impl.h (93%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/assign.cpp (99%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/buffer.cpp (92%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/buffer.h (99%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/character.cpp (99%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/command.cpp (98%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/complex-powi.cpp (91%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/complex-reduction.c (97%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/complex-reduction.h (97%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/connection.cpp (96%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/connection.h (98%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/copy.cpp (99%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/copy.h (93%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/derived-api.cpp (98%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/derived.cpp (99%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/derived.h (94%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/descriptor-io.cpp (98%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/descriptor-io.h (99%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/descriptor.cpp (99%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/dot-product.cpp (99%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/edit-input.cpp (99%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/edit-input.h (95%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/edit-output.cpp (99%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/edit-output.h (98%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/emit-encoded.h (98%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/environment-default-list.h (85%)
 mode change 100755 => 100644
 rename {flang/runtime => FortranRuntime/lib/Runtime}/environment.cpp (98%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/environment.h (95%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/exceptions.cpp (96%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/execute.cpp (99%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/extensions.cpp (98%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/external-unit.cpp (99%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/extrema.cpp (99%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/file.cpp (99%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/file.h (98%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/findloc.cpp (99%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/format-implementation.h (99%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/format.cpp (92%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/format.h (98%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/inquiry.cpp (97%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/internal-unit.cpp (98%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/internal-unit.h (97%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/io-api-common.h (98%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/io-api-minimal.cpp (98%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/io-api.cpp (99%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/io-error.cpp (98%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/io-error.h (97%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/io-stmt.cpp (99%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/io-stmt.h (99%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/iostat.cpp (98%)
 rename {flang/module => FortranRuntime/lib/Runtime}/iso_fortran_env_impl.f90 (98%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/lock.h (97%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/main.cpp (94%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/matmul-transpose.cpp (99%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/matmul.cpp (99%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/memory.cpp (93%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/misc-intrinsic.cpp (98%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/namelist.cpp (99%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/namelist.h (96%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/non-tbp-dio.cpp (93%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/non-tbp-dio.h (93%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/numeric-templates.h (99%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/numeric.cpp (99%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/pointer.cpp (99%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/product.cpp (98%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/pseudo-unit.cpp (98%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/ragged.cpp (97%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/random-templates.h (97%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/random.cpp (98%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/reduce.cpp (99%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/reduction-templates.h (99%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/reduction.cpp (99%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/stack.h (98%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/stat.cpp (97%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/stat.h (95%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/stop.cpp (98%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/sum.cpp (98%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/support.cpp (94%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/temporary-stack.cpp (98%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/terminator.cpp (97%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/terminator.h (98%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/time-intrinsic.cpp (99%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/tools.cpp (99%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/tools.h (99%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/transformational.cpp (99%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/type-code.cpp (98%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/type-info.cpp (99%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/type-info.h (99%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/unit-map.cpp (97%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/unit-map.h (97%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/unit.cpp (99%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/unit.h (99%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/utf.cpp (98%)
 rename {flang/runtime => FortranRuntime/lib/Runtime}/utf.h (97%)
 create mode 100644 FortranRuntime/lib/Testing/CMakeLists.txt
 rename {flang/unittests/Evaluate => FortranRuntime/lib/Testing}/fp-testing.cpp (86%)
 rename {flang/unittests/Evaluate => FortranRuntime/lib/Testing}/testing.cpp (88%)
 rename {flang => FortranRuntime}/module/.clang-format (100%)
 create mode 100644 FortranRuntime/module/CMakeLists.txt
 rename {flang => FortranRuntime}/module/__cuda_builtins.f90 (100%)
 rename {flang => FortranRuntime}/module/__fortran_builtins.f90 (100%)
 rename {flang => FortranRuntime}/module/__fortran_ieee_exceptions.f90 (100%)
 rename {flang => FortranRuntime}/module/__fortran_type_info.f90 (100%)
 rename {flang => FortranRuntime}/module/__ppc_intrinsics.f90 (100%)
 rename {flang => FortranRuntime}/module/__ppc_types.f90 (100%)
 rename {flang => FortranRuntime}/module/cudadevice.f90 (96%)
 rename {flang => FortranRuntime}/module/ieee_arithmetic.f90 (100%)
 rename {flang => FortranRuntime}/module/ieee_exceptions.f90 (100%)
 rename {flang => FortranRuntime}/module/ieee_features.f90 (100%)
 rename {flang => FortranRuntime}/module/iso_c_binding.f90 (100%)
 rename {flang => FortranRuntime}/module/iso_fortran_env.f90 (100%)
 rename {flang => FortranRuntime}/module/mma.f90 (98%)
 create mode 100644 FortranRuntime/test/CMakeLists.txt
 create mode 100644 FortranRuntime/test/NonGtestUnit/lit.cfg.py
 create mode 100644 FortranRuntime/test/NonGtestUnit/lit.site.cfg.py.in
 rename {flang => FortranRuntime}/test/Runtime/no-cpp-dep.c (75%)
 create mode 100644 FortranRuntime/test/Unit/lit.cfg.py
 create mode 100644 FortranRuntime/test/Unit/lit.site.cfg.py.in
 create mode 100644 FortranRuntime/test/lit.cfg.py
 create mode 100644 FortranRuntime/test/lit.site.cfg.py.in
 create mode 100644 FortranRuntime/unittests/CMakeLists.txt
 create mode 100644 FortranRuntime/unittests/Common/CMakeLists.txt
 rename {flang => FortranRuntime}/unittests/Common/FastIntSetTest.cpp (97%)
 create mode 100644 FortranRuntime/unittests/Decimal/CMakeLists.txt
 rename {flang => FortranRuntime}/unittests/Decimal/quick-sanity-test.cpp (91%)
 rename {flang => FortranRuntime}/unittests/Decimal/thorough-test.cpp (85%)
 create mode 100644 FortranRuntime/unittests/Evaluate/CMakeLists.txt
 rename {flang => FortranRuntime}/unittests/Evaluate/ISO-Fortran-binding.cpp (98%)
 rename {flang => FortranRuntime}/unittests/Evaluate/reshape.cpp (88%)
 rename {flang => FortranRuntime}/unittests/Runtime/AccessTest.cpp (99%)
 rename {flang => FortranRuntime}/unittests/Runtime/Allocatable.cpp (98%)
 rename {flang => FortranRuntime}/unittests/Runtime/ArrayConstructor.cpp (99%)
 rename {flang => FortranRuntime}/unittests/Runtime/BufferTest.cpp (97%)
 rename {flang => FortranRuntime}/unittests/Runtime/CMakeLists.txt (54%)
 rename {flang => FortranRuntime}/unittests/Runtime/CUDA/AllocatorCUF.cpp (95%)
 rename {flang => FortranRuntime}/unittests/Runtime/CharacterTest.cpp (99%)
 rename {flang => FortranRuntime}/unittests/Runtime/CommandTest.cpp (99%)
 rename {flang => FortranRuntime}/unittests/Runtime/Complex.cpp (98%)
 rename {flang => FortranRuntime}/unittests/Runtime/CrashHandlerFixture.cpp (92%)
 rename {flang => FortranRuntime}/unittests/Runtime/CrashHandlerFixture.h (91%)
 rename {flang => FortranRuntime}/unittests/Runtime/Derived.cpp (96%)
 rename {flang => FortranRuntime}/unittests/Runtime/ExternalIOTest.cpp (99%)
 rename {flang => FortranRuntime}/unittests/Runtime/Format.cpp (96%)
 rename {flang => FortranRuntime}/unittests/Runtime/Inquiry.cpp (98%)
 rename {flang => FortranRuntime}/unittests/Runtime/ListInputTest.cpp (98%)
 rename {flang => FortranRuntime}/unittests/Runtime/LogicalFormatTest.cpp (96%)
 rename {flang => FortranRuntime}/unittests/Runtime/Matmul.cpp (99%)
 rename {flang => FortranRuntime}/unittests/Runtime/MatmulTranspose.cpp (99%)
 rename {flang => FortranRuntime}/unittests/Runtime/MiscIntrinsic.cpp (98%)
 rename {flang => FortranRuntime}/unittests/Runtime/Namelist.cpp (99%)
 rename {flang => FortranRuntime}/unittests/Runtime/Numeric.cpp (99%)
 rename {flang => FortranRuntime}/unittests/Runtime/NumericalFormatTest.cpp (99%)
 rename {flang => FortranRuntime}/unittests/Runtime/Pointer.cpp (98%)
 rename {flang => FortranRuntime}/unittests/Runtime/Ragged.cpp (94%)
 rename {flang => FortranRuntime}/unittests/Runtime/Random.cpp (97%)
 rename {flang => FortranRuntime}/unittests/Runtime/Reduction.cpp (99%)
 rename {flang => FortranRuntime}/unittests/Runtime/RuntimeCrashTest.cpp (98%)
 rename {flang => FortranRuntime}/unittests/Runtime/Stop.cpp (96%)
 rename {flang => FortranRuntime}/unittests/Runtime/Support.cpp (97%)
 rename {flang => FortranRuntime}/unittests/Runtime/TemporaryStack.cpp (98%)
 rename {flang => FortranRuntime}/unittests/Runtime/Time.cpp (98%)
 rename {flang => FortranRuntime}/unittests/Runtime/Transformational.cpp (99%)
 rename {flang => FortranRuntime}/unittests/Runtime/tools.h (96%)
 rename flang/include/flang/{Common => Support}/Fortran-features.h (98%)
 rename flang/include/flang/{Common => Support}/Fortran.h (73%)
 rename flang/include/flang/{Common => Support}/MathOptionsBase.def (100%)
 rename flang/include/flang/{Common => Support}/MathOptionsBase.h (86%)
 rename flang/include/flang/{Common => Support}/OpenMP-features.h (94%)
 rename flang/include/flang/{Common => Support}/Version.h (95%)
 rename flang/include/flang/{Common => Support}/default-kinds.h (96%)
 rename flang/include/flang/{Common => Support}/indirection.h (98%)
 rename flang/include/flang/{Common => Support}/interval.h (97%)
 rename flang/include/flang/{Common => Support}/reference-counted.h (96%)
 rename flang/include/flang/{Common => Support}/reference.h (97%)
 rename flang/include/flang/{Common => Support}/static-multimap-view.h (97%)
 rename flang/include/flang/{Common => Support}/template.h (99%)
 rename flang/include/flang/{Common => Support}/unwrap.h (97%)
 delete mode 100644 flang/lib/Decimal/CMakeLists.txt
 create mode 100644 flang/lib/Support/CMakeLists.txt
 rename flang/lib/{Common => Support}/Fortran-features.cpp (91%)
 rename flang/lib/{Common => Support}/Fortran.cpp (96%)
 rename flang/lib/{Common => Support}/Version.cpp (95%)
 create mode 100644 flang/lib/Support/big-radix-floating-point.h
 rename flang/lib/{Common => Support}/default-kinds.cpp (94%)
 rename flang/lib/{Common => Support}/idioms.cpp (89%)
 delete mode 100644 flang/runtime/CMakeLists.txt
 delete mode 100644 flang/tools/f18/CMakeLists.txt
 delete mode 100644 flang/tools/f18/dump.cpp
 delete mode 100644 flang/unittests/Common/CMakeLists.txt
 delete mode 100644 flang/unittests/Decimal/CMakeLists.txt
 delete mode 100644 flang/unittests/Runtime/CUDA/CMakeLists.txt

diff --git a/FortranRuntime/.clang-format b/FortranRuntime/.clang-format
new file mode 100644
index 00000000000000..c1dfe06fdf5782
--- /dev/null
+++ b/FortranRuntime/.clang-format
@@ -0,0 +1,21 @@
+---
+# See: https://clang.llvm.org/docs/ClangFormatStyleOptions.html
+BasedOnStyle: LLVM
+AlignAfterOpenBracket: DontAlign
+AlignEscapedNewlines: DontAlign
+AlignConsecutiveAssignments: false
+AlignConsecutiveDeclarations: false
+AlignOperands: false
+AlignTrailingComments: false
+IncludeCategories:
+  - Regex:           '^<'
+    Priority:        4
+  - Regex:           '^"(llvm|llvm-c|clang|clang-c)/'
+    Priority:        3
+  - Regex:           '^"(flang|\.\.)/'
+    Priority:        2
+  - Regex:           '.*'
+    Priority:        1
+...
+
+# vim:set filetype=yaml:
diff --git a/FortranRuntime/CMakeLists.txt b/FortranRuntime/CMakeLists.txt
new file mode 100644
index 00000000000000..765e1445fc1a18
--- /dev/null
+++ b/FortranRuntime/CMakeLists.txt
@@ -0,0 +1,184 @@
+#===-- CMakeLists.txt ------------------------------------------------------===#
+#
+# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+# See https://llvm.org/LICENSE.txt for license information.
+# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+#
+#===------------------------------------------------------------------------===#
+#
+# Build instructions for the FortranRuntime library and Fortran modules required
+# by programs compiled by Flang. This is file is intended to be included using
+# the LLVM_ENABLE_RUNTIMES mechanism.
+#
+#===------------------------------------------------------------------------===#
+
+set(LLVM_SUBPROJECT_TITLE "Fortran Runtime")
+set(FORTRANRUNTIME_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
+set(FORTRANRUNTIME_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}")
+
+list(APPEND CMAKE_MODULE_PATH
+  "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules"
+  )
+include(AddFortranRuntime)
+
+
+
+############################
+# Build Mode Introspection #
+############################
+
+# Setting these variables from an LLVM build is sufficient that FortranRuntime can
+# construct the output paths, so it can behave as if it were in-tree here.
+set(LLVM_TREE_AVAILABLE OFF)
+if (LLVM_LIBRARY_OUTPUT_INTDIR AND LLVM_RUNTIME_OUTPUT_INTDIR AND PACKAGE_VERSION)
+  # This is a bootstap build
+  set(LLVM_TREE_AVAILABLE ON)
+endif()
+
+if (LLVM_TREE_AVAILABLE)
+  # Despite Clang in the name, get_clang_resource_dir does not depend on Clang being added to the build
+  # flang-new uses the same resource dir as clang.
+  include(GetClangResourceDir) 
+  get_clang_resource_dir(FORTRANRUNTIME_BUILD_LIB_DIR PREFIX "${LLVM_LIBRARY_OUTPUT_INTDIR}/.." SUBDIR "lib${LLVM_LIBDIR_SUFFIX}")
+  get_clang_resource_dir(FORTRANRUNTIME_INSTALL_LIB_DIR SUBDIR "lib${LLVM_LIBDIR_SUFFIX}") # No prefix, CMake's install command find the install prefix itself
+
+  # FIXME: If compiling multiple triples, include dirs overwrite each other
+  get_clang_resource_dir(FORTRANRUNTIME_BUILD_INCLUDE_DIR PREFIX "${LLVM_LIBRARY_OUTPUT_INTDIR}/.." SUBDIR "include")
+  get_clang_resource_dir(FORTRANRUNTIME_INSTALL_INCLUDE_DIR SUBDIR "include") 
+else ()
+  set(FORTRANRUNTIME_BUILD_LIB_DIR "${LLVM_LIBRARY_OUTPUT_INTDIR}")
+  set(FORTRANRUNTIME_INSTALL_LIB_DIR "lib${LLVM_LIBDIR_SUFFIX}")
+
+  set(FORTRANRUNTIME_BUILD_INCLUDE_DIR "${LLVM_INCLUDE_DIR}")
+  set(FORTRANRUNTIME_INSTALL_INCLUDE_DIR "include")
+endif ()
+
+
+if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR)
+  set(FORTRANRUNTIME_BUILD_LIB_DIR "${FORTRANRUNTIME_BUILD_LIB_DIR}/${LLVM_TARGET_TRIPLE}")
+  set(FORTRANRUNTIME_INSTALL_LIB_DIR "${FORTRANRUNTIME_INSTALL_LIB_DIR}/${LLVM_TARGET_TRIPLE}")
+endif()
+
+
+
+
+#################
+# Build Options #
+#################
+
+option(FORTRANRUNTIME_INCLUDE_TESTS
+         "Generate build targets for the FortranRuntime unit tests."
+         ${LLVM_INCLUDE_TESTS})
+
+# The out of tree builds of the compiler and the Fortran runtime
+# must use the same setting of FLANG_RUNTIME_F128_MATH_LIB
+# to be composable. Failure to synchronize this setting may result
+# in linking errors or fatal failures in F128 runtime functions.
+set(FORTRARUNTIME_F128_MATH_LIB "" CACHE STRING
+  "Specifies the target library used for implementing IEEE-754 128-bit float \
+  math in F18 runtime, e.g. it might be libquadmath for targets where \
+  REAL(16) is mapped to __float128, or libm for targets where REAL(16) \
+  is mapped to long double, etc."
+  )
+if (FLANG_RUNTIME_F128_MATH_LIB)
+  add_compile_definitions(
+    FLANG_RUNTIME_F128_MATH_LIB="${FLANG_RUNTIME_F128_MATH_LIB}"
+    )
+endif()
+
+option(FLANG_EXPERIMENTAL_CUDA_RUNTIME "Compile Fortran runtime as CUDA sources (experimental)" OFF)
+if (FLANG_EXPERIMENTAL_CUDA_RUNTIME)
+  message(FATAL_ERROOR "FLANG_EXPERIMENTAL_CUDA_RUNTIME currently not supported")
+endif()
+
+
+
+
+########################
+# System Introspection #
+########################
+
+include(TestBigEndian)
+test_big_endian(IS_BIGENDIAN)
+if (IS_BIGENDIAN)
+  add_compile_definitions(FLANG_BIG_ENDIAN=1)
+else ()
+  add_compile_definitions(FLANG_LITTLE_ENDIAN=1)
+endif ()
+
+include(CheckCXXSymbolExists)
+include(CheckCXXSourceCompiles)
+check_cxx_symbol_exists(strerror_r string.h HAVE_STRERROR_R)
+# Can't use symbol exists here as the function is overloaded in C++
+check_cxx_source_compiles(
+  "#include <string.h>
+   int main() {
+     char buf[4096];
+     return strerror_s(buf, 4096, 0);
+   }
+  "
+  HAVE_DECL_STRERROR_S)
+
+# Check if 128-bit float computations can be done via long double
+check_cxx_source_compiles(
+  "#include <cfloat>
+   #if LDBL_MANT_DIG != 113
+   #error LDBL_MANT_DIG != 113
+   #endif
+   int main() { return 0; }
+  "
+  HAVE_LDBL_MANT_DIG_113)
+
+# Check if 128-bit float computations can be done via long double
+check_cxx_source_compiles(
+  "#include <cfloat>
+   #if LDBL_MANT_DIG != 113
+   #error LDBL_MANT_DIG != 113
+   #endif
+   int main() { return 0; }
+  "
+  HAVE_LDBL_MANT_DIG_113)
+
+
+#####################
+# Build Preparation #
+#####################
+
+enable_language(Fortran)
+
+# C++17 required for FortranRuntime, user or other runtimes may override this.
+# GTest included later also requires C++17.
+set(CMAKE_CXX_STANDARD 17 CACHE STRING "C++ standard to conform to") 
+set(CMAKE_CXX_STANDARD_REQUIRED YES)
+
+# Disable libstdc++/libc++ assertions, even in an LLVM_ENABLE_ASSERTIONS build,
+# to avoid an unwanted dependency on libstdc++/libc++.so.
+add_definitions(-U_GLIBCXX_ASSERTIONS)
+add_definitions(-U_LIBCPP_ENABLE_ASSERTIONS)
+
+
+configure_file(cmake/config.h.cmake.in config.h)
+
+configure_file(
+  "${FORTRANRUNTIME_SOURCE_DIR}/include/flang/Common/ISO_Fortran_binding.h"
+  "${FORTRANRUNTIME_BUILD_INCLUDE_DIR}/ISO_Fortran_binding.h"
+)
+install(
+  FILES   "${FORTRANRUNTIME_BUILD_INCLUDE_DIR}/ISO_Fortran_binding.h"
+  DESTINATION "${FORTRANRUNTIME_BUILD_INCLUDE_DIR}"
+)
+
+
+
+###################
+# Build Artifacts #
+###################
+
+add_subdirectory(lib)
+add_subdirectory(module)
+
+if (FORTRANRUNTIME_INCLUDE_TESTS)
+  add_subdirectory(unittests)
+  add_subdirectory(test)
+endif()
+
diff --git a/FortranRuntime/CODE_OWNERS.TXT b/FortranRuntime/CODE_OWNERS.TXT
new file mode 100644
index 00000000000000..649243aa1e8fec
--- /dev/null
+++ b/FortranRuntime/CODE_OWNERS.TXT
@@ -0,0 +1,14 @@
+This file is a list of the people responsible for ensuring that patches for a
+particular part of Flang are reviewed, either by themself or by someone else.
+They are also the gatekeepers for their part of Flang, with the final word on
+what goes in or not.
+
+The list is sorted by surname and formatted to allow easy grepping and
+beautification by scripts. The fields are: name (N), email (E), web-address
+(W), PGP key ID and fingerprint (P), description (D), snail-mail address
+(S) and (I) IRC handle. Each entry should contain at least the (N), (E) and
+(D) fields.
+
+N: Steve Scalpone
+E: sscalpone at nvidia.com
+D: Anything not covered by others
diff --git a/FortranRuntime/LICENSE.TXT b/FortranRuntime/LICENSE.TXT
new file mode 100644
index 00000000000000..53bb2e7fbc7643
--- /dev/null
+++ b/FortranRuntime/LICENSE.TXT
@@ -0,0 +1,234 @@
+==============================================================================
+The LLVM Project is under the Apache License v2.0 with LLVM Exceptions:
+==============================================================================
+
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+    TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+    1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+    2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+    3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+    4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+    5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+    6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+    7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+    8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+    9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+    END OF TERMS AND CONDITIONS
+
+    APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+    Copyright [yyyy] [name of copyright owner]
+
+    Licensed under the Apache License, Version 2.0 (the "License");
+    you may not use this file except in compliance with the License.
+    You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+
+
+---- LLVM Exceptions to the Apache 2.0 License ----
+
+As an exception, if, as a result of your compiling your source code, portions
+of this Software are embedded into an Object form of such source code, you
+may redistribute such embedded portions in such Object form without complying
+with the conditions of Sections 4(a), 4(b) and 4(d) of the License.
+
+In addition, if you combine or link compiled forms of this Software with
+software that is licensed under the GPLv2 ("Combined Software") and if a
+court of competent jurisdiction determines that the patent provision (Section
+3), the indemnity provision (Section 9) or other Section of the License
+conflicts with the conditions of the GPLv2, you may retroactively and
+prospectively choose to deem waived or otherwise exclude such Section(s) of
+the License, but only in their entirety and only with respect to the Combined
+Software.
+
+==============================================================================
+Software from third parties included in the LLVM Project:
+==============================================================================
+The LLVM Project contains third party software which is under different license
+terms. All such code will be identified clearly using at least one of two
+mechanisms:
+1) It will be in a separate directory tree with its own `LICENSE.txt` or
+   `LICENSE` file at the top containing the specific license and restrictions
+   which apply to that software, or
+2) It will contain specific license and restriction terms at the top of every
+   file.
diff --git a/FortranRuntime/README.md b/FortranRuntime/README.md
new file mode 100644
index 00000000000000..6fd4b3359f7888
--- /dev/null
+++ b/FortranRuntime/README.md
@@ -0,0 +1,20 @@
+# Fortran Runtime
+
+Fortran Runtime is the runtime library for code emitted by the Flang
+compiler (https://flang.llvm.org).
+
+## Getting Started
+
+### Bootstrap Build
+
+```sh
+cmake -S <path-to-llvm-project>/llvm -DLLVM_ENABLE_PROJECTS=flang -DLLVM_ENABLE_RUNTIMES=FortranRuntime
+```
+
+### Runtime-only build
+
+```sh
+cmake -S <path-to-llvm-project>/runtimes -DLLVM_ENABLE_RUNTIMES=FortranRuntime -DCMAKE_Fortran_COMPILER=<path-to-llvm-builddir-or-installprefix>/bin/flang-new
+```
+
+
diff --git a/flang/runtime/config.h.cmake b/FortranRuntime/cmake/config.h.cmake.in
similarity index 100%
rename from flang/runtime/config.h.cmake
rename to FortranRuntime/cmake/config.h.cmake.in
diff --git a/FortranRuntime/cmake/modules/AddFortranRuntime.cmake b/FortranRuntime/cmake/modules/AddFortranRuntime.cmake
new file mode 100644
index 00000000000000..a4fc95495610cc
--- /dev/null
+++ b/FortranRuntime/cmake/modules/AddFortranRuntime.cmake
@@ -0,0 +1,109 @@
+#===-- cmake/modules/AddFortranRuntime.cmake -------------------------------===#
+#
+# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+# See https://llvm.org/LICENSE.txt for license information.
+# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+#
+#===------------------------------------------------------------------------===#
+
+# Builds a library with common option for FortranRuntime.
+#
+# Usage:
+#
+# add_fortranruntime_library(name sources ...
+#   SHARED
+#     Build a dynamic (.so/.dll) library
+#   STATIC
+#     Build a static (.a/.lib) library
+#   OBJECT
+#     Create only object- and Fortran module files without static/dynamic library
+#   INSTALL_WITH_TOOLCHAIN
+#     Install library into Clang's resource directory so it can be found by the Flang driver during compilation, including tests
+#   EXCLUDE_FROM_ALL
+#     Do not build library by default; typically used for libraries needed for testing only, no install
+#   LINK_TO_LLVM
+#     Library requires include path and linking to LLVM's Support component
+#   ADDITIONAL_HEADERS
+#     May specify header files for IDE generators.
+# )
+function (add_fortranruntime_library name)
+  set(options STATIC SHARED OBJECT INSTALL_WITH_TOOLCHAIN EXCLUDE_FROM_ALL LINK_TO_LLVM)
+  set(multiValueArgs ADDITIONAL_HEADERS)
+  cmake_parse_arguments(ARG
+    "${options}"
+    ""
+    "${multiValueArgs}"
+    ${ARGN})
+
+  # Also add header files to IDEs to list as part of the library
+  set_source_files_properties(${ARG_ADDITIONAL_HEADERS} PROPERTIES HEADER_FILE_ONLY ON)
+
+  # Forward libtype to add_library
+  set(extra_args "")
+  if (ARG_SHARED)
+    list(APPEND extra_args SHARED)
+  endif ()
+  if (ARG_STATIC)
+    list(APPEND extra_args STATIC)
+  endif ()
+  if (ARG_OBJECT)
+    list(APPEND extra_args OBJECT)
+  endif ()
+  if (EXCLUDE_FROM_ALL)
+    list(APPEND extra_args EXCLUDE_FROM_ALL)
+  endif ()
+
+  add_library(${name} ${extra_args} ${ARG_ADDITIONAL_HEADERS} ${ARG_UNPARSED_ARGUMENTS}   )
+  if (ARG_INSTALL_WITH_TOOLCHAIN)
+    set_target_properties(${name} PROPERTIES FOLDER "Fortran Runtime/Toolchain Libraries")
+  elseif (ARG_OBJECT)
+    set_target_properties(${name} PROPERTIES FOLDER "Fortran Runtime/Object Libraries")
+  else ()
+    set_target_properties(${name} PROPERTIES FOLDER "Fortran Runtime/Libraries")
+  endif ()
+
+  target_compile_features(${name} PRIVATE cxx_std_17)
+     if(LLVM_COMPILER_IS_GCC_COMPATIBLE)
+       target_compile_options (${name} PRIVATE $<$<COMPILE_LANGUAGE:CXX>:-fno-exceptions -fno-rtti -fno-unwind-tables -fno-asynchronous-unwind-tables>)
+    elseif(MSVC)
+      target_compile_options(${name} PRIVATE $<$<COMPILE_LANGUAGE:CXX>:/EHs-c- /GR->)
+    endif()
+
+  target_include_directories(${name} PRIVATE "${FORTRANRUNTIME_BINARY_DIR}")   # For configured config.h for be found
+  target_include_directories(${name} PRIVATE "${FORTRANRUNTIME_SOURCE_DIR}/include")
+
+set_target_properties(${name}
+  PROPERTIES
+    Fortran_MODULE_DIRECTORY "${FORTRANRUNTIME_BUILD_INCLUDE_DIR}/flang"
+)
+
+  if (ARG_LINK_TO_LLVM)
+    if (LLVM_LINK_LLVM_DYLIB)
+      set(llvm_libs LLVM)
+    else()
+      llvm_map_components_to_libnames(llvm_libs Support)
+    endif()
+    target_link_libraries(${name} PUBLIC  ${llvm_libs})
+     target_include_directories(${name} PRIVATE  ${LLVM_INCLUDE_DIRS})
+  endif ()
+
+  # If this is part of the toolchain, put it into the compiler's resource directory.
+  # Otherwise it is part of testing and is not installed at all.
+  # TODO: Consider multi-configuration builds
+  if (INSTALL_WITH_TOOLCHAIN)
+    set_target_properties(${name}
+      PROPERTIES 
+        LIBRARY_OUTPUT_DIRECTORY "${FORTRANRUNTIME_BUILD_LIB_DIR}"
+        ARCHIVE_OUTPUT_DIRECTORY "${FORTRANRUNTIME_BUILD_LIB_DIR}"
+        RUNTIME_OUTPUT_DIRECTORY "${FORTRANRUNTIME_BUILD_LIB_DIR}"
+    )
+
+    if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
+      install(TARGETS ${name}
+        LIBRARY DESTINATION "${FORTRANRUNTIME_INSTALL_LIB_DIR}"
+        ARCHIVE DESTINATION "${FORTRANRUNTIME_INSTALL_LIB_DIR}"
+        RUNTIME DESTINATION "${FORTRANRUNTIME_INSTALL_LIB_DIR}"
+      )
+    endif ()
+  endif ()
+endfunction (add_fortranruntime_library)
diff --git a/FortranRuntime/include/flang/Common/Fortran-consts.h b/FortranRuntime/include/flang/Common/Fortran-consts.h
new file mode 100644
index 00000000000000..3156c6c50c3b9a
--- /dev/null
+++ b/FortranRuntime/include/flang/Common/Fortran-consts.h
@@ -0,0 +1,50 @@
+//===-- include/flang/Common/Fortran-consts.h -------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef FORTRAN_COMMON_FORTRAN_CONSTS_H_
+#define FORTRAN_COMMON_FORTRAN_CONSTS_H_
+
+// Fortran language concepts that are used in many phases are defined
+// once here to avoid redundancy and needless translation.
+
+#include "flang/Common/enum-class.h"
+#include <cstdint>
+
+namespace Fortran::common {
+
+// Fortran has five kinds of intrinsic data types, plus the derived types.
+ENUM_CLASS(TypeCategory, Integer, Real, Complex, Character, Logical, Derived)
+ENUM_CLASS(VectorElementCategory, Integer, Unsigned, Real)
+
+
+ENUM_CLASS(IoStmtKind, None, Backspace, Close, Endfile, Flush, Inquire, Open,
+    Print, Read, Rewind, Wait, Write)
+
+// Defined I/O variants
+ENUM_CLASS(
+    DefinedIo, ReadFormatted, ReadUnformatted, WriteFormatted, WriteUnformatted)
+
+// Fortran arrays may have up to 15 dimensions (See Fortran 2018 section 5.4.6).
+static constexpr int maxRank{15};
+
+
+// Floating-point rounding modes; these are packed into a byte to save
+// room in the runtime's format processing context structure.  These
+// enumerators are defined with the corresponding values returned from
+// llvm.get.rounding.
+enum class RoundingMode : std::uint8_t {
+  ToZero, // ROUND=ZERO, RZ - truncation
+  TiesToEven, // ROUND=NEAREST, RN - default IEEE rounding
+  Up, // ROUND=UP, RU
+  Down, // ROUND=DOWN, RD
+  TiesAwayFromZero, // ROUND=COMPATIBLE, RC - ties round away from zero
+};
+
+
+} // namespace Fortran::common
+#endif // FORTRAN_COMMON_FORTRAN_CONSTS_H_
diff --git a/flang/include/flang/ISO_Fortran_binding.h b/FortranRuntime/include/flang/Common/ISO_Fortran_binding.h
similarity index 97%
rename from flang/include/flang/ISO_Fortran_binding.h
rename to FortranRuntime/include/flang/Common/ISO_Fortran_binding.h
index 89a10ce69a2ba2..21247103bcc552 100644
--- a/flang/include/flang/ISO_Fortran_binding.h
+++ b/FortranRuntime/include/flang/Common/ISO_Fortran_binding.h
@@ -1,11 +1,10 @@
-/*===-- include/flang/ISO_Fortran_binding.h -----------------------*- C++ -*-===
+/*===-- include/flang/Common/ISO_Fortran_binding.h ------------------*- C -*-===
  *
  * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  * See https://llvm.org/LICENSE.txt for license information.
  * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  *
- * ===-----------------------------------------------------------------------===
- */
+ *===----------------------------------------------------------------------===*/
 
 #ifndef CFI_ISO_FORTRAN_BINDING_H_
 #define CFI_ISO_FORTRAN_BINDING_H_
diff --git a/flang/include/flang/ISO_Fortran_binding_wrapper.h b/FortranRuntime/include/flang/Common/ISO_Fortran_binding_wrapper.h
similarity index 85%
rename from flang/include/flang/ISO_Fortran_binding_wrapper.h
rename to FortranRuntime/include/flang/Common/ISO_Fortran_binding_wrapper.h
index 37289bdbabd03c..ee02f6f129732e 100644
--- a/flang/include/flang/ISO_Fortran_binding_wrapper.h
+++ b/FortranRuntime/include/flang/Common/ISO_Fortran_binding_wrapper.h
@@ -1,11 +1,10 @@
-/*===-- include/flang/ISO_Fortran_binding_wrapper.h ---------------*- C++ -*-===
+/*===-- include/flang/Common/ISO_Fortran_binding_wrapper.h ----------*- C -*-===
  *
  * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  * See https://llvm.org/LICENSE.txt for license information.
  * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  *
- * ===-----------------------------------------------------------------------===
- */
+ *===----------------------------------------------------------------------===*/
 
 #ifndef FORTRAN_ISO_FORTRAN_BINDING_WRAPPER_H_
 #define FORTRAN_ISO_FORTRAN_BINDING_WRAPPER_H_
@@ -23,7 +22,7 @@
 
 /* clang-format off */
 #include <stddef.h>
-#include "Common/api-attrs.h"
+#include "flang/Common/api-attrs.h"
 #ifdef __cplusplus
 namespace Fortran {
 namespace ISO {
diff --git a/flang/include/flang/Common/api-attrs.h b/FortranRuntime/include/flang/Common/api-attrs.h
similarity index 99%
rename from flang/include/flang/Common/api-attrs.h
rename to FortranRuntime/include/flang/Common/api-attrs.h
index d73e60996bc81f..b56a3c8a047af6 100644
--- a/flang/include/flang/Common/api-attrs.h
+++ b/FortranRuntime/include/flang/Common/api-attrs.h
@@ -1,11 +1,10 @@
-/*===-- include/flang/Common/api-attrs.h ---------------------------*- C -*-=//
+/*===-- include/flang/Common/api-attrs.h ----------------------------*- C -*-===
  *
  * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  * See https://llvm.org/LICENSE.txt for license information.
  * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  *
- *===------------------------------------------------------------------------===
- */
+ *===----------------------------------------------------------------------===*/
 
 /*
  * The file defines a set macros that can be used to apply
diff --git a/flang/include/flang/Decimal/binary-floating-point.h b/FortranRuntime/include/flang/Common/binary-floating-point.h
similarity index 99%
rename from flang/include/flang/Decimal/binary-floating-point.h
rename to FortranRuntime/include/flang/Common/binary-floating-point.h
index 1e0cde97d98e61..1409b94192740c 100644
--- a/flang/include/flang/Decimal/binary-floating-point.h
+++ b/FortranRuntime/include/flang/Common/binary-floating-point.h
@@ -1,4 +1,4 @@
-//===-- include/flang/Decimal/binary-floating-point.h -----------*- C++ -*-===//
+//===-- include/flang/Common/binary-floating-point.h ------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/include/flang/Common/bit-population-count.h b/FortranRuntime/include/flang/Common/bit-population-count.h
similarity index 100%
rename from flang/include/flang/Common/bit-population-count.h
rename to FortranRuntime/include/flang/Common/bit-population-count.h
diff --git a/flang/include/flang/Common/constexpr-bitset.h b/FortranRuntime/include/flang/Common/constexpr-bitset.h
similarity index 100%
rename from flang/include/flang/Common/constexpr-bitset.h
rename to FortranRuntime/include/flang/Common/constexpr-bitset.h
diff --git a/flang/include/flang/Decimal/decimal.h b/FortranRuntime/include/flang/Common/decimal.h
similarity index 97%
rename from flang/include/flang/Decimal/decimal.h
rename to FortranRuntime/include/flang/Common/decimal.h
index 443163d058e28b..2a75b98c112225 100644
--- a/flang/include/flang/Decimal/decimal.h
+++ b/FortranRuntime/include/flang/Common/decimal.h
@@ -1,11 +1,10 @@
-/*===-- include/flang/Decimal/decimal.h ---------------------------*- C++ -*-===
+/*===-- include/flang/Common/decimal.h ------------------------------*- C -*-===
  *
  * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  * See https://llvm.org/LICENSE.txt for license information.
  * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  *
- * ===-----------------------------------------------------------------------===
- */
+ *===----------------------------------------------------------------------===*/
 
 /* C and C++ API for binary-to/from-decimal conversion package. */
 
diff --git a/flang/include/flang/Common/enum-class.h b/FortranRuntime/include/flang/Common/enum-class.h
similarity index 100%
rename from flang/include/flang/Common/enum-class.h
rename to FortranRuntime/include/flang/Common/enum-class.h
diff --git a/flang/include/flang/Common/enum-set.h b/FortranRuntime/include/flang/Common/enum-set.h
similarity index 100%
rename from flang/include/flang/Common/enum-set.h
rename to FortranRuntime/include/flang/Common/enum-set.h
diff --git a/flang/include/flang/Common/fast-int-set.h b/FortranRuntime/include/flang/Common/fast-int-set.h
similarity index 99%
rename from flang/include/flang/Common/fast-int-set.h
rename to FortranRuntime/include/flang/Common/fast-int-set.h
index d1c9c756a44a65..48209a773c4cd1 100644
--- a/flang/include/flang/Common/fast-int-set.h
+++ b/FortranRuntime/include/flang/Common/fast-int-set.h
@@ -1,4 +1,4 @@
-//===-- include/flang/Common/fast-int-set.h --------------------*- C++ -*-===//
+//===-- include/flang/Common/fast-int-set.h ---------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/include/flang/Common/float128.h b/FortranRuntime/include/flang/Common/float128.h
similarity index 96%
rename from flang/include/flang/Common/float128.h
rename to FortranRuntime/include/flang/Common/float128.h
index 2e76bc0a162e61..a7036bf679e5ae 100644
--- a/flang/include/flang/Common/float128.h
+++ b/FortranRuntime/include/flang/Common/float128.h
@@ -1,4 +1,4 @@
-/*===-- flang/Common/float128.h ----------------------------------*- C -*-===
+/*===-- include/flang/Common/float128.h -----------------------------*- C -*-===
  *
  * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  * See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/include/flang/Common/format.h b/FortranRuntime/include/flang/Common/format.h
similarity index 99%
rename from flang/include/flang/Common/format.h
rename to FortranRuntime/include/flang/Common/format.h
index 2374ff6983cf41..138e84b72b733d 100644
--- a/flang/include/flang/Common/format.h
+++ b/FortranRuntime/include/flang/Common/format.h
@@ -10,7 +10,7 @@
 #define FORTRAN_COMMON_FORMAT_H_
 
 #include "enum-set.h"
-#include "flang/Common/Fortran.h"
+#include "flang/Common/Fortran-consts.h"
 #include <cstring>
 
 // Define a FormatValidator class template to validate a format expression
diff --git a/flang/include/flang/Common/idioms.h b/FortranRuntime/include/flang/Common/idioms.h
similarity index 100%
rename from flang/include/flang/Common/idioms.h
rename to FortranRuntime/include/flang/Common/idioms.h
diff --git a/flang/include/flang/Common/leading-zero-bit-count.h b/FortranRuntime/include/flang/Common/leading-zero-bit-count.h
similarity index 100%
rename from flang/include/flang/Common/leading-zero-bit-count.h
rename to FortranRuntime/include/flang/Common/leading-zero-bit-count.h
diff --git a/flang/include/flang/Common/optional.h b/FortranRuntime/include/flang/Common/optional.h
similarity index 100%
rename from flang/include/flang/Common/optional.h
rename to FortranRuntime/include/flang/Common/optional.h
diff --git a/flang/include/flang/Common/real.h b/FortranRuntime/include/flang/Common/real.h
similarity index 100%
rename from flang/include/flang/Common/real.h
rename to FortranRuntime/include/flang/Common/real.h
diff --git a/flang/include/flang/Common/reference-wrapper.h b/FortranRuntime/include/flang/Common/reference-wrapper.h
similarity index 100%
rename from flang/include/flang/Common/reference-wrapper.h
rename to FortranRuntime/include/flang/Common/reference-wrapper.h
diff --git a/flang/include/flang/Common/restorer.h b/FortranRuntime/include/flang/Common/restorer.h
similarity index 100%
rename from flang/include/flang/Common/restorer.h
rename to FortranRuntime/include/flang/Common/restorer.h
diff --git a/FortranRuntime/include/flang/Common/target-rounding.h b/FortranRuntime/include/flang/Common/target-rounding.h
new file mode 100644
index 00000000000000..970d8fb61fbd1b
--- /dev/null
+++ b/FortranRuntime/include/flang/Common/target-rounding.h
@@ -0,0 +1,40 @@
+//===-- include/flang/Common/target-rounding.h ------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef FORTRAN_COMMON_TARGET_ROUNDING_H_
+#define FORTRAN_COMMON_TARGET_ROUNDING_H_
+
+
+#include "flang/Common/Fortran-consts.h"
+#include "flang/Common/enum-set.h"
+
+
+namespace Fortran::common {
+
+// Floating-point rounding control
+struct Rounding {
+  common::RoundingMode mode{common::RoundingMode::TiesToEven};
+  // When set, emulate status flag behavior peculiar to x86
+  // (viz., fail to set the Underflow flag when an inexact product of a
+  // multiplication is rounded up to a normal number from a subnormal
+  // in some rounding modes)
+#if __x86_64__ || __riscv || __loongarch__
+  bool x86CompatibleBehavior{true};
+#else
+  bool x86CompatibleBehavior{false};
+#endif
+};
+
+
+// These are ordered like the bits in a common fenv.h header file.
+ENUM_CLASS(RealFlag, InvalidArgument, Denorm, DivideByZero, Overflow, Underflow,
+    Inexact)
+using RealFlags = common::EnumSet<RealFlag, RealFlag_enumSize>;
+
+}
+#endif // FORTRAN_COMMON_TARGET_ROUNDING_H_
diff --git a/flang/include/flang/Common/uint128.h b/FortranRuntime/include/flang/Common/uint128.h
similarity index 100%
rename from flang/include/flang/Common/uint128.h
rename to FortranRuntime/include/flang/Common/uint128.h
diff --git a/flang/include/flang/Common/variant.h b/FortranRuntime/include/flang/Common/variant.h
similarity index 100%
rename from flang/include/flang/Common/variant.h
rename to FortranRuntime/include/flang/Common/variant.h
diff --git a/flang/include/flang/Common/visit.h b/FortranRuntime/include/flang/Common/visit.h
similarity index 100%
rename from flang/include/flang/Common/visit.h
rename to FortranRuntime/include/flang/Common/visit.h
diff --git a/flang/include/flang/Common/windows-include.h b/FortranRuntime/include/flang/Common/windows-include.h
similarity index 100%
rename from flang/include/flang/Common/windows-include.h
rename to FortranRuntime/include/flang/Common/windows-include.h
diff --git a/flang/include/flang/Runtime/CUDA/allocator.h b/FortranRuntime/include/flang/Runtime/CUDA/allocator.h
similarity index 100%
rename from flang/include/flang/Runtime/CUDA/allocator.h
rename to FortranRuntime/include/flang/Runtime/CUDA/allocator.h
diff --git a/flang/include/flang/Runtime/CUDA/descriptor.h b/FortranRuntime/include/flang/Runtime/CUDA/descriptor.h
similarity index 100%
rename from flang/include/flang/Runtime/CUDA/descriptor.h
rename to FortranRuntime/include/flang/Runtime/CUDA/descriptor.h
diff --git a/flang/include/flang/Runtime/allocatable.h b/FortranRuntime/include/flang/Runtime/allocatable.h
similarity index 100%
rename from flang/include/flang/Runtime/allocatable.h
rename to FortranRuntime/include/flang/Runtime/allocatable.h
diff --git a/flang/include/flang/Runtime/allocator-registry.h b/FortranRuntime/include/flang/Runtime/allocator-registry.h
similarity index 96%
rename from flang/include/flang/Runtime/allocator-registry.h
rename to FortranRuntime/include/flang/Runtime/allocator-registry.h
index acfada506fafc6..411cc68f58ec33 100644
--- a/flang/include/flang/Runtime/allocator-registry.h
+++ b/FortranRuntime/include/flang/Runtime/allocator-registry.h
@@ -1,4 +1,4 @@
-//===-- runtime/allocator-registry.h ----------------------------*- C++ -*-===//
+//===-- include/flang/Runtime/allocator-registry.h --------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/include/flang/Runtime/array-constructor.h b/FortranRuntime/include/flang/Runtime/array-constructor.h
similarity index 100%
rename from flang/include/flang/Runtime/array-constructor.h
rename to FortranRuntime/include/flang/Runtime/array-constructor.h
diff --git a/flang/include/flang/Runtime/assign.h b/FortranRuntime/include/flang/Runtime/assign.h
similarity index 100%
rename from flang/include/flang/Runtime/assign.h
rename to FortranRuntime/include/flang/Runtime/assign.h
diff --git a/flang/include/flang/Runtime/c-or-cpp.h b/FortranRuntime/include/flang/Runtime/c-or-cpp.h
similarity index 100%
rename from flang/include/flang/Runtime/c-or-cpp.h
rename to FortranRuntime/include/flang/Runtime/c-or-cpp.h
diff --git a/flang/include/flang/Runtime/character.h b/FortranRuntime/include/flang/Runtime/character.h
similarity index 100%
rename from flang/include/flang/Runtime/character.h
rename to FortranRuntime/include/flang/Runtime/character.h
diff --git a/flang/include/flang/Runtime/command.h b/FortranRuntime/include/flang/Runtime/command.h
similarity index 100%
rename from flang/include/flang/Runtime/command.h
rename to FortranRuntime/include/flang/Runtime/command.h
diff --git a/flang/include/flang/Runtime/cpp-type.h b/FortranRuntime/include/flang/Runtime/cpp-type.h
similarity index 98%
rename from flang/include/flang/Runtime/cpp-type.h
rename to FortranRuntime/include/flang/Runtime/cpp-type.h
index fe21dd544cf7d8..27b43de7d0f0f6 100644
--- a/flang/include/flang/Runtime/cpp-type.h
+++ b/FortranRuntime/include/flang/Runtime/cpp-type.h
@@ -11,7 +11,7 @@
 #ifndef FORTRAN_RUNTIME_CPP_TYPE_H_
 #define FORTRAN_RUNTIME_CPP_TYPE_H_
 
-#include "flang/Common/Fortran.h"
+#include "flang/Common/Fortran-consts.h"
 #include "flang/Common/float128.h"
 #include "flang/Common/uint128.h"
 #include <complex>
diff --git a/flang/include/flang/Runtime/derived-api.h b/FortranRuntime/include/flang/Runtime/derived-api.h
similarity index 100%
rename from flang/include/flang/Runtime/derived-api.h
rename to FortranRuntime/include/flang/Runtime/derived-api.h
diff --git a/flang/include/flang/Runtime/descriptor.h b/FortranRuntime/include/flang/Runtime/descriptor.h
similarity index 99%
rename from flang/include/flang/Runtime/descriptor.h
rename to FortranRuntime/include/flang/Runtime/descriptor.h
index 030d0c1031fbaa..2fe5b11200cf6d 100644
--- a/flang/include/flang/Runtime/descriptor.h
+++ b/FortranRuntime/include/flang/Runtime/descriptor.h
@@ -18,7 +18,7 @@
 // User C code is welcome to depend on that ISO_Fortran_binding.h file,
 // but should never reference this internal header.
 
-#include "flang/ISO_Fortran_binding_wrapper.h"
+#include "flang/Common/ISO_Fortran_binding_wrapper.h"
 #include "flang/Runtime/memory.h"
 #include "flang/Runtime/type-code.h"
 #include <algorithm>
diff --git a/flang/include/flang/Runtime/entry-names.h b/FortranRuntime/include/flang/Runtime/entry-names.h
similarity index 97%
rename from flang/include/flang/Runtime/entry-names.h
rename to FortranRuntime/include/flang/Runtime/entry-names.h
index 68582b92b54941..52de2496d9421d 100644
--- a/flang/include/flang/Runtime/entry-names.h
+++ b/FortranRuntime/include/flang/Runtime/entry-names.h
@@ -1,11 +1,10 @@
-/*===-- include/flang/Runtime/entry-names.h -------------------------*- C -*-=//
+/*===-- include/flang/Runtime/entry-names.h -------------------------*- C -*-===
  *
  * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  * See https://llvm.org/LICENSE.txt for license information.
  * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  *
- *===------------------------------------------------------------------------===
- */
+ *===----------------------------------------------------------------------===*/
 
 /* Defines the macro RTNAME(n) which decorates the external name of a runtime
  * library function or object with extra characters so that it
diff --git a/flang/include/flang/Runtime/exceptions.h b/FortranRuntime/include/flang/Runtime/exceptions.h
similarity index 91%
rename from flang/include/flang/Runtime/exceptions.h
rename to FortranRuntime/include/flang/Runtime/exceptions.h
index 1ab22da103a50f..1fb74e14e54d30 100644
--- a/flang/include/flang/Runtime/exceptions.h
+++ b/FortranRuntime/include/flang/Runtime/exceptions.h
@@ -1,4 +1,4 @@
-//===-- include/flang/Runtime/exceptions.h ----------------*- C++ -*-===//
+//===-- include/flang/Runtime/exceptions.h ----------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/include/flang/Runtime/execute.h b/FortranRuntime/include/flang/Runtime/execute.h
similarity index 93%
rename from flang/include/flang/Runtime/execute.h
rename to FortranRuntime/include/flang/Runtime/execute.h
index ca137b9d1823c4..ba3e950ca92941 100644
--- a/flang/include/flang/Runtime/execute.h
+++ b/FortranRuntime/include/flang/Runtime/execute.h
@@ -1,4 +1,4 @@
-//===-- include/flang/Runtime/command.h -------------------------*- C++ -*-===//
+//===-- include/flang/Runtime/execute.h -------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/include/flang/Runtime/extensions.h b/FortranRuntime/include/flang/Runtime/extensions.h
similarity index 100%
rename from flang/include/flang/Runtime/extensions.h
rename to FortranRuntime/include/flang/Runtime/extensions.h
diff --git a/flang/include/flang/Runtime/freestanding-tools.h b/FortranRuntime/include/flang/Runtime/freestanding-tools.h
similarity index 100%
rename from flang/include/flang/Runtime/freestanding-tools.h
rename to FortranRuntime/include/flang/Runtime/freestanding-tools.h
diff --git a/flang/include/flang/Runtime/inquiry.h b/FortranRuntime/include/flang/Runtime/inquiry.h
similarity index 94%
rename from flang/include/flang/Runtime/inquiry.h
rename to FortranRuntime/include/flang/Runtime/inquiry.h
index c7a7487f1a1b18..36ef929ed5b2f1 100644
--- a/flang/include/flang/Runtime/inquiry.h
+++ b/FortranRuntime/include/flang/Runtime/inquiry.h
@@ -1,4 +1,4 @@
-//===-- include/flang/Runtime/inquiry.h ----------------*- C++ -*-===//
+//===-- include/flang/Runtime/inquiry.h -------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/include/flang/Runtime/io-api.h b/FortranRuntime/include/flang/Runtime/io-api.h
similarity index 100%
rename from flang/include/flang/Runtime/io-api.h
rename to FortranRuntime/include/flang/Runtime/io-api.h
diff --git a/flang/include/flang/Runtime/iostat.h b/FortranRuntime/include/flang/Runtime/iostat.h
similarity index 100%
rename from flang/include/flang/Runtime/iostat.h
rename to FortranRuntime/include/flang/Runtime/iostat.h
diff --git a/flang/include/flang/Runtime/magic-numbers.h b/FortranRuntime/include/flang/Runtime/magic-numbers.h
similarity index 98%
rename from flang/include/flang/Runtime/magic-numbers.h
rename to FortranRuntime/include/flang/Runtime/magic-numbers.h
index bab0e9ae05299a..931df690766219 100644
--- a/flang/include/flang/Runtime/magic-numbers.h
+++ b/FortranRuntime/include/flang/Runtime/magic-numbers.h
@@ -1,10 +1,10 @@
-#if 0 /*===-- include/flang/Runtime/magic-numbers.h -----------------------===*/
-/*
+#if 0 /*===-- include/flang/Runtime/magic-numbers.h ---------------*- C -*-===*/
+ *
  * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  * See https://llvm.org/LICENSE.txt for license information.
  * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  *
- *===----------------------------------------------------------------------===*/
+/*===----------------------------------------------------------------------===*/
 #endif
 #if 0
 This header can be included into both Fortran and C.
diff --git a/flang/include/flang/Runtime/main.h b/FortranRuntime/include/flang/Runtime/main.h
similarity index 100%
rename from flang/include/flang/Runtime/main.h
rename to FortranRuntime/include/flang/Runtime/main.h
diff --git a/flang/include/flang/Runtime/matmul-instances.inc b/FortranRuntime/include/flang/Runtime/matmul-instances.inc
similarity index 100%
rename from flang/include/flang/Runtime/matmul-instances.inc
rename to FortranRuntime/include/flang/Runtime/matmul-instances.inc
diff --git a/flang/include/flang/Runtime/matmul-transpose.h b/FortranRuntime/include/flang/Runtime/matmul-transpose.h
similarity index 100%
rename from flang/include/flang/Runtime/matmul-transpose.h
rename to FortranRuntime/include/flang/Runtime/matmul-transpose.h
diff --git a/flang/include/flang/Runtime/matmul.h b/FortranRuntime/include/flang/Runtime/matmul.h
similarity index 100%
rename from flang/include/flang/Runtime/matmul.h
rename to FortranRuntime/include/flang/Runtime/matmul.h
diff --git a/flang/include/flang/Runtime/memory.h b/FortranRuntime/include/flang/Runtime/memory.h
similarity index 100%
rename from flang/include/flang/Runtime/memory.h
rename to FortranRuntime/include/flang/Runtime/memory.h
diff --git a/flang/include/flang/Runtime/misc-intrinsic.h b/FortranRuntime/include/flang/Runtime/misc-intrinsic.h
similarity index 100%
rename from flang/include/flang/Runtime/misc-intrinsic.h
rename to FortranRuntime/include/flang/Runtime/misc-intrinsic.h
diff --git a/flang/include/flang/Runtime/numeric.h b/FortranRuntime/include/flang/Runtime/numeric.h
similarity index 100%
rename from flang/include/flang/Runtime/numeric.h
rename to FortranRuntime/include/flang/Runtime/numeric.h
diff --git a/flang/include/flang/Runtime/pointer.h b/FortranRuntime/include/flang/Runtime/pointer.h
similarity index 100%
rename from flang/include/flang/Runtime/pointer.h
rename to FortranRuntime/include/flang/Runtime/pointer.h
diff --git a/flang/include/flang/Runtime/ragged.h b/FortranRuntime/include/flang/Runtime/ragged.h
similarity index 97%
rename from flang/include/flang/Runtime/ragged.h
rename to FortranRuntime/include/flang/Runtime/ragged.h
index f52a619c55b43e..ff157ea16f081e 100644
--- a/flang/include/flang/Runtime/ragged.h
+++ b/FortranRuntime/include/flang/Runtime/ragged.h
@@ -1,4 +1,4 @@
-//===-- Runtime/ragged.h ----------------------------------------*- C++ -*-===//
+//===-- include/flang/Runtime/ragged.h --------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/include/flang/Runtime/random.h b/FortranRuntime/include/flang/Runtime/random.h
similarity index 100%
rename from flang/include/flang/Runtime/random.h
rename to FortranRuntime/include/flang/Runtime/random.h
diff --git a/flang/include/flang/Runtime/reduce.h b/FortranRuntime/include/flang/Runtime/reduce.h
similarity index 100%
rename from flang/include/flang/Runtime/reduce.h
rename to FortranRuntime/include/flang/Runtime/reduce.h
diff --git a/flang/include/flang/Runtime/reduction.h b/FortranRuntime/include/flang/Runtime/reduction.h
similarity index 100%
rename from flang/include/flang/Runtime/reduction.h
rename to FortranRuntime/include/flang/Runtime/reduction.h
diff --git a/flang/include/flang/Runtime/stop.h b/FortranRuntime/include/flang/Runtime/stop.h
similarity index 100%
rename from flang/include/flang/Runtime/stop.h
rename to FortranRuntime/include/flang/Runtime/stop.h
diff --git a/flang/include/flang/Runtime/support.h b/FortranRuntime/include/flang/Runtime/support.h
similarity index 96%
rename from flang/include/flang/Runtime/support.h
rename to FortranRuntime/include/flang/Runtime/support.h
index ba9c2598bb0ddd..4a6d4357e87103 100644
--- a/flang/include/flang/Runtime/support.h
+++ b/FortranRuntime/include/flang/Runtime/support.h
@@ -10,7 +10,7 @@
 #ifndef FORTRAN_RUNTIME_SUPPORT_H_
 #define FORTRAN_RUNTIME_SUPPORT_H_
 
-#include "flang/ISO_Fortran_binding_wrapper.h"
+#include "flang/Common/ISO_Fortran_binding_wrapper.h"
 #include "flang/Runtime/entry-names.h"
 #include <cstddef>
 #include <cstdint>
diff --git a/flang/include/flang/Runtime/temporary-stack.h b/FortranRuntime/include/flang/Runtime/temporary-stack.h
similarity index 100%
rename from flang/include/flang/Runtime/temporary-stack.h
rename to FortranRuntime/include/flang/Runtime/temporary-stack.h
diff --git a/flang/include/flang/Runtime/time-intrinsic.h b/FortranRuntime/include/flang/Runtime/time-intrinsic.h
similarity index 100%
rename from flang/include/flang/Runtime/time-intrinsic.h
rename to FortranRuntime/include/flang/Runtime/time-intrinsic.h
diff --git a/flang/include/flang/Runtime/transformational.h b/FortranRuntime/include/flang/Runtime/transformational.h
similarity index 100%
rename from flang/include/flang/Runtime/transformational.h
rename to FortranRuntime/include/flang/Runtime/transformational.h
diff --git a/flang/include/flang/Runtime/type-code.h b/FortranRuntime/include/flang/Runtime/type-code.h
similarity index 96%
rename from flang/include/flang/Runtime/type-code.h
rename to FortranRuntime/include/flang/Runtime/type-code.h
index 8e7314e0af1efc..3c1b03dfaa1140 100644
--- a/flang/include/flang/Runtime/type-code.h
+++ b/FortranRuntime/include/flang/Runtime/type-code.h
@@ -9,9 +9,9 @@
 #ifndef FORTRAN_RUNTIME_TYPE_CODE_H_
 #define FORTRAN_RUNTIME_TYPE_CODE_H_
 
-#include "flang/Common/Fortran.h"
+#include "flang/Common/Fortran-consts.h"
 #include "flang/Common/optional.h"
-#include "flang/ISO_Fortran_binding_wrapper.h"
+#include "flang/Common/ISO_Fortran_binding_wrapper.h"
 #include <utility>
 
 namespace Fortran::runtime {
diff --git a/flang/unittests/Evaluate/fp-testing.h b/FortranRuntime/include/flang/Testing/fp-testing.h
similarity index 56%
rename from flang/unittests/Evaluate/fp-testing.h
rename to FortranRuntime/include/flang/Testing/fp-testing.h
index 22dfa2d7d80c60..16c6017e8529d5 100644
--- a/flang/unittests/Evaluate/fp-testing.h
+++ b/FortranRuntime/include/flang/Testing/fp-testing.h
@@ -1,12 +1,20 @@
+//===-- include/flang/Testing/fp-testing.h ----------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
 #ifndef FORTRAN_TEST_EVALUATE_FP_TESTING_H_
 #define FORTRAN_TEST_EVALUATE_FP_TESTING_H_
 
-#include "flang/Evaluate/target.h"
+#include "flang/Common/target-rounding.h"
 #include <fenv.h>
 
 using Fortran::common::RoundingMode;
-using Fortran::evaluate::RealFlags;
-using Fortran::evaluate::Rounding;
+using Fortran::common::RealFlags;
+using Fortran::common::Rounding;
 
 class ScopedHostFloatingPointEnvironment {
 public:
diff --git a/flang/unittests/Evaluate/testing.h b/FortranRuntime/include/flang/Testing/testing.h
similarity index 80%
rename from flang/unittests/Evaluate/testing.h
rename to FortranRuntime/include/flang/Testing/testing.h
index 422e2853c05bc6..d763109d62d373 100644
--- a/flang/unittests/Evaluate/testing.h
+++ b/FortranRuntime/include/flang/Testing/testing.h
@@ -1,3 +1,11 @@
+//===-- include/flang/Testing/testing.h -------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
 #ifndef FORTRAN_EVALUATE_TESTING_H_
 #define FORTRAN_EVALUATE_TESTING_H_
 
diff --git a/FortranRuntime/lib/CMakeLists.txt b/FortranRuntime/lib/CMakeLists.txt
new file mode 100644
index 00000000000000..8c4382078a8e70
--- /dev/null
+++ b/FortranRuntime/lib/CMakeLists.txt
@@ -0,0 +1,12 @@
+#===-- lib/CMakeLists.txt --------------------------------------------------===#
+#
+# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+# See https://llvm.org/LICENSE.txt for license information.
+# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+#
+#===------------------------------------------------------------------------===#
+
+add_subdirectory(Runtime)
+if (FORTRANRUNTIME_INCLUDE_TESTS)
+  add_subdirectory(Testing)
+endif ()
diff --git a/flang/lib/Decimal/big-radix-floating-point.h b/FortranRuntime/lib/Common/big-radix-floating-point.h
similarity index 98%
rename from flang/lib/Decimal/big-radix-floating-point.h
rename to FortranRuntime/lib/Common/big-radix-floating-point.h
index f9afebf5b3d703..7b8fb03710a3d4 100644
--- a/flang/lib/Decimal/big-radix-floating-point.h
+++ b/FortranRuntime/lib/Common/big-radix-floating-point.h
@@ -1,4 +1,4 @@
-//===-- lib/Decimal/big-radix-floating-point.h ------------------*- C++ -*-===//
+//===-- lib/Common/big-radix-floating-point.h -------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -24,8 +24,8 @@
 #include "flang/Common/bit-population-count.h"
 #include "flang/Common/leading-zero-bit-count.h"
 #include "flang/Common/uint128.h"
-#include "flang/Decimal/binary-floating-point.h"
-#include "flang/Decimal/decimal.h"
+#include "flang/Common/binary-floating-point.h"
+#include "flang/Common/decimal.h"
 #include <cinttypes>
 #include <limits>
 #include <type_traits>
diff --git a/flang/lib/Decimal/binary-to-decimal.cpp b/FortranRuntime/lib/Common/binary-to-decimal.cpp
similarity index 99%
rename from flang/lib/Decimal/binary-to-decimal.cpp
rename to FortranRuntime/lib/Common/binary-to-decimal.cpp
index b64865e95df24d..fb2caefdae8fa1 100644
--- a/flang/lib/Decimal/binary-to-decimal.cpp
+++ b/FortranRuntime/lib/Common/binary-to-decimal.cpp
@@ -1,4 +1,4 @@
-//===-- lib/Decimal/binary-to-decimal.cpp ---------------------------------===//
+//===-- lib/Common/binary-to-decimal.cpp ------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -7,7 +7,7 @@
 //===----------------------------------------------------------------------===//
 
 #include "big-radix-floating-point.h"
-#include "flang/Decimal/decimal.h"
+#include "flang/Common/decimal.h"
 #include <cassert>
 #include <cfloat>
 #include <string>
diff --git a/flang/lib/Decimal/decimal-to-binary.cpp b/FortranRuntime/lib/Common/decimal-to-binary.cpp
similarity index 99%
rename from flang/lib/Decimal/decimal-to-binary.cpp
rename to FortranRuntime/lib/Common/decimal-to-binary.cpp
index 94c51774237399..0ef24d3bcfecfc 100644
--- a/flang/lib/Decimal/decimal-to-binary.cpp
+++ b/FortranRuntime/lib/Common/decimal-to-binary.cpp
@@ -1,4 +1,4 @@
-//===-- lib/Decimal/decimal-to-binary.cpp ---------------------------------===//
+//===-- lib/Common/decimal-to-binary.cpp ------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -9,8 +9,8 @@
 #include "big-radix-floating-point.h"
 #include "flang/Common/bit-population-count.h"
 #include "flang/Common/leading-zero-bit-count.h"
-#include "flang/Decimal/binary-floating-point.h"
-#include "flang/Decimal/decimal.h"
+#include "flang/Common/binary-floating-point.h"
+#include "flang/Common/decimal.h"
 #include "flang/Runtime/freestanding-tools.h"
 #include <cinttypes>
 #include <cstring>
diff --git a/FortranRuntime/lib/Runtime/CMakeLists.txt b/FortranRuntime/lib/Runtime/CMakeLists.txt
new file mode 100644
index 00000000000000..3402dd5fe6af8f
--- /dev/null
+++ b/FortranRuntime/lib/Runtime/CMakeLists.txt
@@ -0,0 +1,242 @@
+#===-- lib/Runtime/CMakeLists.txt ------------------------------------------===#
+#
+# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+# See https://llvm.org/LICENSE.txt for license information.
+# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+#
+#===------------------------------------------------------------------------===#
+
+add_subdirectory(Float128Math)
+
+set(sources
+  ISO_Fortran_binding.cpp
+  allocator-registry.cpp
+  allocatable.cpp
+  array-constructor.cpp
+  assign.cpp
+  buffer.cpp
+  character.cpp
+  command.cpp
+  complex-powi.cpp
+  complex-reduction.c
+  connection.cpp
+  copy.cpp
+  derived-api.cpp
+  derived.cpp
+  descriptor-io.cpp
+  descriptor.cpp
+  dot-product.cpp
+  edit-input.cpp
+  edit-output.cpp
+  environment.cpp
+  exceptions.cpp
+  execute.cpp
+  extensions.cpp
+  external-unit.cpp
+  extrema.cpp
+  file.cpp
+  findloc.cpp
+  format.cpp
+  inquiry.cpp
+  internal-unit.cpp
+  io-api.cpp
+  io-api-minimal.cpp
+  io-error.cpp
+  io-stmt.cpp
+  iso_fortran_env_impl.f90
+  iostat.cpp
+  main.cpp
+  matmul-transpose.cpp
+  matmul.cpp
+  memory.cpp
+  misc-intrinsic.cpp
+  namelist.cpp
+  non-tbp-dio.cpp
+  numeric.cpp
+  pointer.cpp
+  product.cpp
+  pseudo-unit.cpp
+  ragged.cpp
+  random.cpp
+  reduce.cpp
+  reduction.cpp
+  stat.cpp
+  stop.cpp
+  sum.cpp
+  support.cpp
+  temporary-stack.cpp
+  terminator.cpp
+  time-intrinsic.cpp
+  tools.cpp
+  transformational.cpp
+  type-code.cpp
+  type-info.cpp
+  unit-map.cpp
+  unit.cpp
+  utf.cpp
+  ../Common/binary-to-decimal.cpp
+  ../Common/decimal-to-binary.cpp
+)
+
+# List of files that are buildable for all devices.
+set(supported_files
+  ISO_Fortran_binding.cpp
+  allocatable.cpp
+  allocator-registry.cpp
+  array-constructor.cpp
+  assign.cpp
+  buffer.cpp
+  character.cpp
+  connection.cpp
+  copy.cpp
+  derived-api.cpp
+  derived.cpp
+  descriptor.cpp
+  descriptor-io.cpp
+  dot-product.cpp
+  edit-input.cpp
+  edit-output.cpp
+  environment.cpp
+  extrema.cpp
+  external-unit.cpp
+  file.cpp
+  findloc.cpp
+  format.cpp
+  inquiry.cpp
+  internal-unit.cpp
+  io-api.cpp
+  io-api-minimal.cpp
+  io-error.cpp
+  io-stmt.cpp
+  iostat.cpp
+  matmul-transpose.cpp
+  matmul.cpp
+  memory.cpp
+  misc-intrinsic.cpp
+  namelist.cpp
+  non-tbp-dio.cpp
+  numeric.cpp
+  pointer.cpp
+  product.cpp
+  pseudo-unit.cpp
+  ragged.cpp
+  stat.cpp
+  sum.cpp
+  support.cpp
+  terminator.cpp
+  tools.cpp
+  transformational.cpp
+  type-code.cpp
+  type-info.cpp
+  unit.cpp
+  utf.cpp
+  )
+
+
+  set(public_headers "")
+  file(GLOB_RECURSE public_headers 
+    "${FLANGRUNTIME_SOURCE_DIR}/include/flang/Runtime/*.h" 
+    "${FLANGRUNTIME_SOURCE_DIR}/include/flang/Common/*.h" 
+    )
+
+
+  set(private_headers "")
+  file(GLOB_RECURSE private_headers 
+    "${FLANGRUNTIME_SOURCE_DIR}/lib/Runtime/*.h" 
+    "${FLANGRUNTIME_SOURCE_DIR}/lib/Common/*.h" 
+    )
+
+
+
+
+
+
+
+
+
+get_target_property(f128_sources
+  FortranFloat128MathILib INTERFACE_SOURCES
+  )
+if (f128_sources)
+  # The interface may define special macros for Float128Math files,
+  # so we need to propagate them.
+  get_target_property(f128_defs
+    FortranFloat128MathILib INTERFACE_COMPILE_DEFINITIONS
+    )
+  set_property(SOURCE ${f128_sources}
+    APPEND PROPERTY COMPILE_DEFINITIONS
+    ${f128_defs}
+    )
+  list(APPEND sources ${f128_sources})
+endif()
+
+
+
+
+
+
+
+
+
+
+
+
+if (NOT DEFINED WIN32)
+  add_fortranruntime_library(FortranRuntime STATIC
+    ${sources}
+    INSTALL_WITH_TOOLCHAIN
+    ADDITIONAL_HEADERS ${public_headers} ${private_headers}
+  )
+
+  # For unittests that link to FortranRuntime. Should link to the static version of the library.
+  add_library(FortranRuntime.static ALIAS FortranRuntime)
+else()
+  # ${sources} also contains Fortran files. CMake write the generated Fortran files into the same directory (lib/Runtime/iso_fortran_env_impl.mod), so we need to compile it only once and add the object files to different runtime version.
+  add_fortranruntime_library(FortranRuntime.obj OBJECT
+      ${sources}
+ 
+      ADDITIONAL_HEADERS ${public_headers} ${private_headers}
+    )
+
+  set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreaded)
+  add_fortranruntime_library(FortranRuntime.static STATIC $<TARGET_OBJECTS:FortranRuntime.obj> INSTALL_WITH_TOOLCHAIN  #${sources}
+    )
+
+  
+  set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreadedDLL)
+  add_fortranruntime_library(FortranRuntime.dynamic SHARED $<TARGET_OBJECTS:FortranRuntime.obj> INSTALL_WITH_TOOLCHAIN #${sources} 
+    )
+
+  
+  set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreadedDebug)
+  add_fortranruntime_library(FortranRuntime.static_dbg STATIC $<TARGET_OBJECTS:FortranRuntime.obj> INSTALL_WITH_TOOLCHAIN #${sources}
+    )
+
+  set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreadedDebugDLL)
+  add_fortranruntime_library(FortranRuntime.dynamic_dbg SHARED $<TARGET_OBJECTS:FortranRuntime.obj> INSTALL_WITH_TOOLCHAIN #${sources}
+    )
+  target_link_libraries(FortranRuntime.dynamic_dbg PRIVATE FortranRuntime.obj)
+
+  # Target for building all versions of the runtime
+  add_custom_target(FortranRuntime)
+  set_target_properties(FortranRuntime PROPERTIES FOLDER "Fortran Runtime/Meta")
+  add_dependencies(FortranRuntime FortranRuntime.static FortranRuntime.dynamic
+    FortranRuntime.static_dbg FortranRuntime.dynamic_dbg)
+
+  if (MSVC)
+    # The Fortran files compiled with flang-new assumes libcall functions such as `__udivti3`
+    # Add LLVM_ENABLE_RUNTIMES=compiler-rt for it to be available during the runtimes build
+    # FIXME: Can embed linker command --dependent-lib into object files as already done with FortranRuntime.<mode>.lib
+    if (NOT TARGET clang_rt.builtins-x86_64)
+      message(WARNING
+        "compiler-rt needed when compiling with msvc\n"
+        "Flang/LLVM will emit code that calls into libgcc/compiler-rt, but using the MSVC linker will only link Microsoft's CRT automatically\n"
+        "Add compiler-rt to LLVM_ENABLE_RUNTIMES to fix"
+      )
+    endif ()
+    target_link_libraries(FortranRuntime.static PUBLIC clang_rt.builtins-x86_64)
+    target_link_libraries(FortranRuntime.dynamic PUBLIC clang_rt.builtins-x86_64)
+    target_link_libraries(FortranRuntime.static_dbg PUBLIC clang_rt.builtins-x86_64)
+    target_link_libraries(FortranRuntime.dynamic_dbg PUBLIC clang_rt.builtins-x86_64)
+  endif ()
+endif()
diff --git a/flang/runtime/CUDA/CMakeLists.txt b/FortranRuntime/lib/Runtime/CUDA/CMakeLists.txt
similarity index 93%
rename from flang/runtime/CUDA/CMakeLists.txt
rename to FortranRuntime/lib/Runtime/CUDA/CMakeLists.txt
index 81055b2737c0f1..f75b854d1eb3ba 100644
--- a/flang/runtime/CUDA/CMakeLists.txt
+++ b/FortranRuntime/lib/Runtime/CUDA/CMakeLists.txt
@@ -1,4 +1,4 @@
-#===-- runtime/CUDA/CMakeLists.txt -----------------------------------------===#
+#===-- lib/Runtime/CUDA/CMakeLists.txt -------------------------------------===#
 #
 # Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 # See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/CUDA/allocator.cpp b/FortranRuntime/lib/Runtime/CUDA/allocator.cpp
similarity index 94%
rename from flang/runtime/CUDA/allocator.cpp
rename to FortranRuntime/lib/Runtime/CUDA/allocator.cpp
index d4a473d58e86cd..379f52b45057a0 100644
--- a/flang/runtime/CUDA/allocator.cpp
+++ b/FortranRuntime/lib/Runtime/CUDA/allocator.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/CUDA/allocator.cpp ----------------------------------------===//
+//===-- lib/Runtime/CUDA/allocator.cpp --------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -11,7 +11,7 @@
 #include "../stat.h"
 #include "../terminator.h"
 #include "../type-info.h"
-#include "flang/Common/Fortran.h"
+#include "flang/Support/Fortran.h"
 #include "flang/ISO_Fortran_binding_wrapper.h"
 #include "flang/Runtime/allocator-registry.h"
 
diff --git a/flang/runtime/CUDA/descriptor.cpp b/FortranRuntime/lib/Runtime/CUDA/descriptor.cpp
similarity index 91%
rename from flang/runtime/CUDA/descriptor.cpp
rename to FortranRuntime/lib/Runtime/CUDA/descriptor.cpp
index 1031b1e601b646..9664fea4ebc78a 100644
--- a/flang/runtime/CUDA/descriptor.cpp
+++ b/FortranRuntime/lib/Runtime/CUDA/descriptor.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/CUDA/descriptor.cpp ---------------------------------------===//
+//===-- lib/Runtime/CUDA/descriptor.cpp -------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/Float128Math/CMakeLists.txt b/FortranRuntime/lib/Runtime/Float128Math/CMakeLists.txt
similarity index 98%
rename from flang/runtime/Float128Math/CMakeLists.txt
rename to FortranRuntime/lib/Runtime/Float128Math/CMakeLists.txt
index a5f5bec1e7e4b8..1ff158c401855f 100644
--- a/flang/runtime/Float128Math/CMakeLists.txt
+++ b/FortranRuntime/lib/Runtime/Float128Math/CMakeLists.txt
@@ -1,4 +1,4 @@
-#===-- runtime/Float128Math/CMakeLists.txt ---------------------------------===#
+#===-- lib/Runtime/Float128Math/CMakeLists.txt -----------------------------===#
 #
 # Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 # See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/Float128Math/acos.cpp b/FortranRuntime/lib/Runtime/Float128Math/acos.cpp
similarity index 87%
rename from flang/runtime/Float128Math/acos.cpp
rename to FortranRuntime/lib/Runtime/Float128Math/acos.cpp
index 14ff6944856844..7b15e4a0bfd3ae 100644
--- a/flang/runtime/Float128Math/acos.cpp
+++ b/FortranRuntime/lib/Runtime/Float128Math/acos.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/acos.cpp -------------------------------------===//
+//===-- lib/Runtime/Float128Math/acos.cpp -----------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/Float128Math/acosh.cpp b/FortranRuntime/lib/Runtime/Float128Math/acosh.cpp
similarity index 87%
rename from flang/runtime/Float128Math/acosh.cpp
rename to FortranRuntime/lib/Runtime/Float128Math/acosh.cpp
index 9d70804e44a470..c873259b4545b8 100644
--- a/flang/runtime/Float128Math/acosh.cpp
+++ b/FortranRuntime/lib/Runtime/Float128Math/acosh.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/acosh.cpp ------------------------------------===//
+//===-- lib/Runtime/Float128Math/acosh.cpp ----------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/Float128Math/asin.cpp b/FortranRuntime/lib/Runtime/Float128Math/asin.cpp
similarity index 87%
rename from flang/runtime/Float128Math/asin.cpp
rename to FortranRuntime/lib/Runtime/Float128Math/asin.cpp
index 6781b23f0363db..8866d51430197a 100644
--- a/flang/runtime/Float128Math/asin.cpp
+++ b/FortranRuntime/lib/Runtime/Float128Math/asin.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/asin.cpp -------------------------------------===//
+//===-- lib/Runtime/Float128Math/asin.cpp -----------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/Float128Math/asinh.cpp b/FortranRuntime/lib/Runtime/Float128Math/asinh.cpp
similarity index 87%
rename from flang/runtime/Float128Math/asinh.cpp
rename to FortranRuntime/lib/Runtime/Float128Math/asinh.cpp
index 1310bc61c1de0f..288193001ce1da 100644
--- a/flang/runtime/Float128Math/asinh.cpp
+++ b/FortranRuntime/lib/Runtime/Float128Math/asinh.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/asinh.cpp ------------------------------------===//
+//===-- lib/Runtime/Float128Math/asinh.cpp ----------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/Float128Math/atan.cpp b/FortranRuntime/lib/Runtime/Float128Math/atan.cpp
similarity index 87%
rename from flang/runtime/Float128Math/atan.cpp
rename to FortranRuntime/lib/Runtime/Float128Math/atan.cpp
index f01382df90c0ee..390c080b4d501b 100644
--- a/flang/runtime/Float128Math/atan.cpp
+++ b/FortranRuntime/lib/Runtime/Float128Math/atan.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/atan.cpp -------------------------------------===//
+//===-- lib/Runtime/Float128Math/atan.cpp -----------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/Float128Math/atan2.cpp b/FortranRuntime/lib/Runtime/Float128Math/atan2.cpp
similarity index 88%
rename from flang/runtime/Float128Math/atan2.cpp
rename to FortranRuntime/lib/Runtime/Float128Math/atan2.cpp
index dd646b0452b115..3c206b75704431 100644
--- a/flang/runtime/Float128Math/atan2.cpp
+++ b/FortranRuntime/lib/Runtime/Float128Math/atan2.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/atan2.cpp ------------------------------------===//
+//===-- lib/Runtime/Float128Math/atan2.cpp ----------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/Float128Math/atanh.cpp b/FortranRuntime/lib/Runtime/Float128Math/atanh.cpp
similarity index 87%
rename from flang/runtime/Float128Math/atanh.cpp
rename to FortranRuntime/lib/Runtime/Float128Math/atanh.cpp
index 5fc5ba5debc81a..77ceb188f04e42 100644
--- a/flang/runtime/Float128Math/atanh.cpp
+++ b/FortranRuntime/lib/Runtime/Float128Math/atanh.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/atanh.cpp ------------------------------------===//
+//===-- lib/Runtime/Float128Math/atanh.cpp ----------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/Float128Math/ceil.cpp b/FortranRuntime/lib/Runtime/Float128Math/ceil.cpp
similarity index 87%
rename from flang/runtime/Float128Math/ceil.cpp
rename to FortranRuntime/lib/Runtime/Float128Math/ceil.cpp
index ed4d164a62bedc..46bc253bd0922d 100644
--- a/flang/runtime/Float128Math/ceil.cpp
+++ b/FortranRuntime/lib/Runtime/Float128Math/ceil.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/ceil.cpp -------------------------------------===//
+//===-- lib/Runtime/Float128Math/ceil.cpp -----------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/Float128Math/complex-math.c b/FortranRuntime/lib/Runtime/Float128Math/complex-math.c
similarity index 92%
rename from flang/runtime/Float128Math/complex-math.c
rename to FortranRuntime/lib/Runtime/Float128Math/complex-math.c
index d0180c63a0d7bf..f34ef7da76e599 100644
--- a/flang/runtime/Float128Math/complex-math.c
+++ b/FortranRuntime/lib/Runtime/Float128Math/complex-math.c
@@ -1,11 +1,10 @@
-/*===-- runtime/Float128Math/complex-math.c -------------------------*- C -*-===
+/*===-- lib/Runtime/Float128Math/complex-math.c ---------------------*- C -*-===
  *
  * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  * See https://llvm.org/LICENSE.txt for license information.
  * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  *
- * ===-----------------------------------------------------------------------===
- */
+ *===----------------------------------------------------------------------===*/
 
 #include "complex-math.h"
 
diff --git a/flang/runtime/Float128Math/complex-math.h b/FortranRuntime/lib/Runtime/Float128Math/complex-math.h
similarity index 96%
rename from flang/runtime/Float128Math/complex-math.h
rename to FortranRuntime/lib/Runtime/Float128Math/complex-math.h
index 81dd53a175d1aa..6f5c7954bab035 100644
--- a/flang/runtime/Float128Math/complex-math.h
+++ b/FortranRuntime/lib/Runtime/Float128Math/complex-math.h
@@ -1,4 +1,4 @@
-/*===-- runtime/Float128Math/complex-math.h -------------------------*- C -*-===
+/*===-- lib/Runtime/Float128Math/complex-math.h ---------------------*- C -*-===
  *
  * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  * See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/Float128Math/cos.cpp b/FortranRuntime/lib/Runtime/Float128Math/cos.cpp
similarity index 87%
rename from flang/runtime/Float128Math/cos.cpp
rename to FortranRuntime/lib/Runtime/Float128Math/cos.cpp
index b93c92f275f791..8ce47151e2914b 100644
--- a/flang/runtime/Float128Math/cos.cpp
+++ b/FortranRuntime/lib/Runtime/Float128Math/cos.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/cos.cpp --------------------------------------===//
+//===-- lib/Runtime/Float128Math/cos.cpp ------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/Float128Math/cosh.cpp b/FortranRuntime/lib/Runtime/Float128Math/cosh.cpp
similarity index 87%
rename from flang/runtime/Float128Math/cosh.cpp
rename to FortranRuntime/lib/Runtime/Float128Math/cosh.cpp
index a3662a826dcb1c..f1ec45bcfb479d 100644
--- a/flang/runtime/Float128Math/cosh.cpp
+++ b/FortranRuntime/lib/Runtime/Float128Math/cosh.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/cosh.cpp -------------------------------------===//
+//===-- lib/Runtime/Float128Math/cosh.cpp -----------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/Float128Math/erf.cpp b/FortranRuntime/lib/Runtime/Float128Math/erf.cpp
similarity index 87%
rename from flang/runtime/Float128Math/erf.cpp
rename to FortranRuntime/lib/Runtime/Float128Math/erf.cpp
index 631f71c76effe7..010088467794d1 100644
--- a/flang/runtime/Float128Math/erf.cpp
+++ b/FortranRuntime/lib/Runtime/Float128Math/erf.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/erf.cpp --------------------------------------===//
+//===-- lib/Runtime/Float128Math/erf.cpp ------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/Float128Math/erfc.cpp b/FortranRuntime/lib/Runtime/Float128Math/erfc.cpp
similarity index 87%
rename from flang/runtime/Float128Math/erfc.cpp
rename to FortranRuntime/lib/Runtime/Float128Math/erfc.cpp
index ea3cd646d8c4ba..b226f8d2dc378b 100644
--- a/flang/runtime/Float128Math/erfc.cpp
+++ b/FortranRuntime/lib/Runtime/Float128Math/erfc.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/erfc.cpp -------------------------------------===//
+//===-- lib/Runtime/Float128Math/erfc.cpp -----------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/Float128Math/exp.cpp b/FortranRuntime/lib/Runtime/Float128Math/exp.cpp
similarity index 87%
rename from flang/runtime/Float128Math/exp.cpp
rename to FortranRuntime/lib/Runtime/Float128Math/exp.cpp
index b1161b0f29294c..e22f9df3579e96 100644
--- a/flang/runtime/Float128Math/exp.cpp
+++ b/FortranRuntime/lib/Runtime/Float128Math/exp.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/exp.cpp --------------------------------------===//
+//===-- lib/Runtime/Float128Math/exp.cpp ------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/Float128Math/exponent.cpp b/FortranRuntime/lib/Runtime/Float128Math/exponent.cpp
similarity index 90%
rename from flang/runtime/Float128Math/exponent.cpp
rename to FortranRuntime/lib/Runtime/Float128Math/exponent.cpp
index 1be1dd0d0ac8b8..f07bf30bd1096f 100644
--- a/flang/runtime/Float128Math/exponent.cpp
+++ b/FortranRuntime/lib/Runtime/Float128Math/exponent.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/exponent.cpp ---------------------------------===//
+//===-- lib/Runtime/Float128Math/exponent.cpp -------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/Float128Math/floor.cpp b/FortranRuntime/lib/Runtime/Float128Math/floor.cpp
similarity index 87%
rename from flang/runtime/Float128Math/floor.cpp
rename to FortranRuntime/lib/Runtime/Float128Math/floor.cpp
index 78a94984cac8a3..8744e6e2fec63c 100644
--- a/flang/runtime/Float128Math/floor.cpp
+++ b/FortranRuntime/lib/Runtime/Float128Math/floor.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/floor.cpp ------------------------------------===//
+//===-- lib/Runtime/Float128Math/floor.cpp ----------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/Float128Math/fma.cpp b/FortranRuntime/lib/Runtime/Float128Math/fma.cpp
similarity index 89%
rename from flang/runtime/Float128Math/fma.cpp
rename to FortranRuntime/lib/Runtime/Float128Math/fma.cpp
index ec67e8e6fba22b..198fec5d4bc356 100644
--- a/flang/runtime/Float128Math/fma.cpp
+++ b/FortranRuntime/lib/Runtime/Float128Math/fma.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/fma.cpp --------------------------------------===//
+//===-- lib/Runtime/Float128Math/fma.cpp ------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/Float128Math/fraction.cpp b/FortranRuntime/lib/Runtime/Float128Math/fraction.cpp
similarity index 87%
rename from flang/runtime/Float128Math/fraction.cpp
rename to FortranRuntime/lib/Runtime/Float128Math/fraction.cpp
index 8c9889b7f6871e..d4749bf3eb7e0e 100644
--- a/flang/runtime/Float128Math/fraction.cpp
+++ b/FortranRuntime/lib/Runtime/Float128Math/fraction.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/fraction.cpp ---------------------------------===//
+//===-- lib/Runtime/Float128Math/fraction.cpp -------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/Float128Math/hypot.cpp b/FortranRuntime/lib/Runtime/Float128Math/hypot.cpp
similarity index 88%
rename from flang/runtime/Float128Math/hypot.cpp
rename to FortranRuntime/lib/Runtime/Float128Math/hypot.cpp
index b4fa1d66bcfa6a..6542bf505060df 100644
--- a/flang/runtime/Float128Math/hypot.cpp
+++ b/FortranRuntime/lib/Runtime/Float128Math/hypot.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/hypot.cpp ------------------------------------===//
+//===-- lib/Runtime/Float128Math/hypot.cpp ----------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/Float128Math/j0.cpp b/FortranRuntime/lib/Runtime/Float128Math/j0.cpp
similarity index 87%
rename from flang/runtime/Float128Math/j0.cpp
rename to FortranRuntime/lib/Runtime/Float128Math/j0.cpp
index 9390a7eeb3c605..27e4338cdfc2b0 100644
--- a/flang/runtime/Float128Math/j0.cpp
+++ b/FortranRuntime/lib/Runtime/Float128Math/j0.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/j0.cpp ---------------------------------------===//
+//===-- lib/Runtime/Float128Math/j0.cpp -------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/Float128Math/j1.cpp b/FortranRuntime/lib/Runtime/Float128Math/j1.cpp
similarity index 87%
rename from flang/runtime/Float128Math/j1.cpp
rename to FortranRuntime/lib/Runtime/Float128Math/j1.cpp
index c54927123388c6..d3f897827f9f67 100644
--- a/flang/runtime/Float128Math/j1.cpp
+++ b/FortranRuntime/lib/Runtime/Float128Math/j1.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/j1.cpp ---------------------------------------===//
+//===-- lib/Runtime/Float128Math/j1.cpp -------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/Float128Math/jn.cpp b/FortranRuntime/lib/Runtime/Float128Math/jn.cpp
similarity index 87%
rename from flang/runtime/Float128Math/jn.cpp
rename to FortranRuntime/lib/Runtime/Float128Math/jn.cpp
index 15afd83400c320..681bb5b1ff3ad5 100644
--- a/flang/runtime/Float128Math/jn.cpp
+++ b/FortranRuntime/lib/Runtime/Float128Math/jn.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/jn.cpp ---------------------------------------===//
+//===-- lib/Runtime/Float128Math/jn.cpp -------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/Float128Math/lgamma.cpp b/FortranRuntime/lib/Runtime/Float128Math/lgamma.cpp
similarity index 87%
rename from flang/runtime/Float128Math/lgamma.cpp
rename to FortranRuntime/lib/Runtime/Float128Math/lgamma.cpp
index ac31c89a912b32..0426db2e3b98d3 100644
--- a/flang/runtime/Float128Math/lgamma.cpp
+++ b/FortranRuntime/lib/Runtime/Float128Math/lgamma.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/lgamma.cpp -----------------------------------===//
+//===-- lib/Runtime/Float128Math/lgamma.cpp ---------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/Float128Math/llround.cpp b/FortranRuntime/lib/Runtime/Float128Math/llround.cpp
similarity index 88%
rename from flang/runtime/Float128Math/llround.cpp
rename to FortranRuntime/lib/Runtime/Float128Math/llround.cpp
index b77281c507fe7c..4c9026cce00283 100644
--- a/flang/runtime/Float128Math/llround.cpp
+++ b/FortranRuntime/lib/Runtime/Float128Math/llround.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/llround.cpp ----------------------------------===//
+//===-- lib/Runtime/Float128Math/llround.cpp --------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/Float128Math/log.cpp b/FortranRuntime/lib/Runtime/Float128Math/log.cpp
similarity index 87%
rename from flang/runtime/Float128Math/log.cpp
rename to FortranRuntime/lib/Runtime/Float128Math/log.cpp
index 38e6b581fd849c..a5a431ae5ffbbb 100644
--- a/flang/runtime/Float128Math/log.cpp
+++ b/FortranRuntime/lib/Runtime/Float128Math/log.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/log.cpp --------------------------------------===//
+//===-- lib/Runtime/Float128Math/log.cpp ------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/Float128Math/log10.cpp b/FortranRuntime/lib/Runtime/Float128Math/log10.cpp
similarity index 87%
rename from flang/runtime/Float128Math/log10.cpp
rename to FortranRuntime/lib/Runtime/Float128Math/log10.cpp
index 3c89c0e707774f..9a83f57b6c736d 100644
--- a/flang/runtime/Float128Math/log10.cpp
+++ b/FortranRuntime/lib/Runtime/Float128Math/log10.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/log10.cpp ------------------------------------===//
+//===-- lib/Runtime/Float128Math/log10.cpp ----------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/Float128Math/lround.cpp b/FortranRuntime/lib/Runtime/Float128Math/lround.cpp
similarity index 87%
rename from flang/runtime/Float128Math/lround.cpp
rename to FortranRuntime/lib/Runtime/Float128Math/lround.cpp
index ce7a228038a1d3..65546881157948 100644
--- a/flang/runtime/Float128Math/lround.cpp
+++ b/FortranRuntime/lib/Runtime/Float128Math/lround.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/lround.cpp -----------------------------------===//
+//===-- lib/Runtime/Float128Math/lround.cpp ---------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/Float128Math/math-entries.h b/FortranRuntime/lib/Runtime/Float128Math/math-entries.h
similarity index 99%
rename from flang/runtime/Float128Math/math-entries.h
rename to FortranRuntime/lib/Runtime/Float128Math/math-entries.h
index 13fdab26470038..798efdfb1e120c 100644
--- a/flang/runtime/Float128Math/math-entries.h
+++ b/FortranRuntime/lib/Runtime/Float128Math/math-entries.h
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/math-entries.h ---------------------*- C++ -*-===//
+//===-- lib/Runtime/Float128Math/math-entries.h -----------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/Float128Math/mod-real.cpp b/FortranRuntime/lib/Runtime/Float128Math/mod-real.cpp
similarity index 89%
rename from flang/runtime/Float128Math/mod-real.cpp
rename to FortranRuntime/lib/Runtime/Float128Math/mod-real.cpp
index 42e6ce76e2fa1b..e3b96d39e76ae6 100644
--- a/flang/runtime/Float128Math/mod-real.cpp
+++ b/FortranRuntime/lib/Runtime/Float128Math/mod-real.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/mod-real.cpp ---------------------------------===//
+//===-- lib/Runtime/Float128Math/mod-real.cpp -------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/Float128Math/modulo-real.cpp b/FortranRuntime/lib/Runtime/Float128Math/modulo-real.cpp
similarity index 89%
rename from flang/runtime/Float128Math/modulo-real.cpp
rename to FortranRuntime/lib/Runtime/Float128Math/modulo-real.cpp
index 13000aba8c8323..8edf59e9f59dd4 100644
--- a/flang/runtime/Float128Math/modulo-real.cpp
+++ b/FortranRuntime/lib/Runtime/Float128Math/modulo-real.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/modulo-real.cpp ------------------------------===//
+//===-- lib/Runtime/Float128Math/modulo-real.cpp ----------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/Float128Math/nearest.cpp b/FortranRuntime/lib/Runtime/Float128Math/nearest.cpp
similarity index 89%
rename from flang/runtime/Float128Math/nearest.cpp
rename to FortranRuntime/lib/Runtime/Float128Math/nearest.cpp
index 148ac4ef839160..8b9f142d79ff93 100644
--- a/flang/runtime/Float128Math/nearest.cpp
+++ b/FortranRuntime/lib/Runtime/Float128Math/nearest.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/nearest.cpp ----------------------------------===//
+//===-- lib/Runtime/Float128Math/nearest.cpp --------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/Float128Math/norm2.cpp b/FortranRuntime/lib/Runtime/Float128Math/norm2.cpp
similarity index 93%
rename from flang/runtime/Float128Math/norm2.cpp
rename to FortranRuntime/lib/Runtime/Float128Math/norm2.cpp
index 15c482f7f007ce..a0c26e40de0064 100644
--- a/flang/runtime/Float128Math/norm2.cpp
+++ b/FortranRuntime/lib/Runtime/Float128Math/norm2.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/norm2.cpp ------------------------------------===//
+//===-- lib/Runtime/Float128Math/norm2.cpp ----------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/Float128Math/numeric-template-specs.h b/FortranRuntime/lib/Runtime/Float128Math/numeric-template-specs.h
similarity index 96%
rename from flang/runtime/Float128Math/numeric-template-specs.h
rename to FortranRuntime/lib/Runtime/Float128Math/numeric-template-specs.h
index a0a77230c3e9eb..ca9696e18f6a92 100644
--- a/flang/runtime/Float128Math/numeric-template-specs.h
+++ b/FortranRuntime/lib/Runtime/Float128Math/numeric-template-specs.h
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/numeric-template-specs.h -----------*- C++ -*-===//
+//===-- lib/Runtime/Float128Math/numeric-template-specs.h -------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/Float128Math/pow.cpp b/FortranRuntime/lib/Runtime/Float128Math/pow.cpp
similarity index 88%
rename from flang/runtime/Float128Math/pow.cpp
rename to FortranRuntime/lib/Runtime/Float128Math/pow.cpp
index 7a48828ee3e765..c11978ca068f23 100644
--- a/flang/runtime/Float128Math/pow.cpp
+++ b/FortranRuntime/lib/Runtime/Float128Math/pow.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/pow.cpp --------------------------------------===//
+//===-- lib/Runtime/Float128Math/pow.cpp ------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/Float128Math/random.cpp b/FortranRuntime/lib/Runtime/Float128Math/random.cpp
similarity index 89%
rename from flang/runtime/Float128Math/random.cpp
rename to FortranRuntime/lib/Runtime/Float128Math/random.cpp
index cda962b416144e..a9dc3c7a82b673 100644
--- a/flang/runtime/Float128Math/random.cpp
+++ b/FortranRuntime/lib/Runtime/Float128Math/random.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/random.cpp -----------------------------------===//
+//===-- lib/Runtime/Float128Math/random.cpp ---------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/Float128Math/round.cpp b/FortranRuntime/lib/Runtime/Float128Math/round.cpp
similarity index 89%
rename from flang/runtime/Float128Math/round.cpp
rename to FortranRuntime/lib/Runtime/Float128Math/round.cpp
index 6420c1bc9cd25d..5a9366b3af4785 100644
--- a/flang/runtime/Float128Math/round.cpp
+++ b/FortranRuntime/lib/Runtime/Float128Math/round.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/round.cpp ------------------------------------===//
+//===-- lib/Runtime/Float128Math/round.cpp ----------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/Float128Math/rrspacing.cpp b/FortranRuntime/lib/Runtime/Float128Math/rrspacing.cpp
similarity index 87%
rename from flang/runtime/Float128Math/rrspacing.cpp
rename to FortranRuntime/lib/Runtime/Float128Math/rrspacing.cpp
index feddac418eec39..2c501b3512c215 100644
--- a/flang/runtime/Float128Math/rrspacing.cpp
+++ b/FortranRuntime/lib/Runtime/Float128Math/rrspacing.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/rrspacing.cpp --------------------------------===//
+//===-- lib/Runtime/Float128Math/rrspacing.cpp ------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/Float128Math/scale.cpp b/FortranRuntime/lib/Runtime/Float128Math/scale.cpp
similarity index 90%
rename from flang/runtime/Float128Math/scale.cpp
rename to FortranRuntime/lib/Runtime/Float128Math/scale.cpp
index 0be958bd9f2a72..859c955b8114e0 100644
--- a/flang/runtime/Float128Math/scale.cpp
+++ b/FortranRuntime/lib/Runtime/Float128Math/scale.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/scale.cpp ------------------------------------===//
+//===-- lib/Runtime/Float128Math/scale.cpp ----------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/Float128Math/set-exponent.cpp b/FortranRuntime/lib/Runtime/Float128Math/set-exponent.cpp
similarity index 88%
rename from flang/runtime/Float128Math/set-exponent.cpp
rename to FortranRuntime/lib/Runtime/Float128Math/set-exponent.cpp
index 99c34af7962b9a..52258182871a14 100644
--- a/flang/runtime/Float128Math/set-exponent.cpp
+++ b/FortranRuntime/lib/Runtime/Float128Math/set-exponent.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/set-exponent.cpp -----------------------------===//
+//===-- lib/Runtime/Float128Math/set-exponent.cpp ---------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/Float128Math/sin.cpp b/FortranRuntime/lib/Runtime/Float128Math/sin.cpp
similarity index 87%
rename from flang/runtime/Float128Math/sin.cpp
rename to FortranRuntime/lib/Runtime/Float128Math/sin.cpp
index 8ebc3f9881586e..99aa4095c8cf1a 100644
--- a/flang/runtime/Float128Math/sin.cpp
+++ b/FortranRuntime/lib/Runtime/Float128Math/sin.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/sin.cpp --------------------------------------===//
+//===-- lib/Runtime/Float128Math/sin.cpp ------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/Float128Math/sinh.cpp b/FortranRuntime/lib/Runtime/Float128Math/sinh.cpp
similarity index 87%
rename from flang/runtime/Float128Math/sinh.cpp
rename to FortranRuntime/lib/Runtime/Float128Math/sinh.cpp
index aa716a3e51ef5a..a7dfe36737de43 100644
--- a/flang/runtime/Float128Math/sinh.cpp
+++ b/FortranRuntime/lib/Runtime/Float128Math/sinh.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/sinh.cpp -------------------------------------===//
+//===-- lib/Runtime/Float128Math/sinh.cpp -----------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/Float128Math/spacing.cpp b/FortranRuntime/lib/Runtime/Float128Math/spacing.cpp
similarity index 87%
rename from flang/runtime/Float128Math/spacing.cpp
rename to FortranRuntime/lib/Runtime/Float128Math/spacing.cpp
index a86c0b30e567ab..66a01851965840 100644
--- a/flang/runtime/Float128Math/spacing.cpp
+++ b/FortranRuntime/lib/Runtime/Float128Math/spacing.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/spacing.cpp ----------------------------------===//
+//===-- lib/Runtime/Float128Math/spacing.cpp --------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/Float128Math/sqrt.cpp b/FortranRuntime/lib/Runtime/Float128Math/sqrt.cpp
similarity index 87%
rename from flang/runtime/Float128Math/sqrt.cpp
rename to FortranRuntime/lib/Runtime/Float128Math/sqrt.cpp
index 83165a4c623191..cbc1e503d50fd9 100644
--- a/flang/runtime/Float128Math/sqrt.cpp
+++ b/FortranRuntime/lib/Runtime/Float128Math/sqrt.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/sqrt.cpp -------------------------------------===//
+//===-- lib/Runtime/Float128Math/sqrt.cpp -----------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/Float128Math/tan.cpp b/FortranRuntime/lib/Runtime/Float128Math/tan.cpp
similarity index 87%
rename from flang/runtime/Float128Math/tan.cpp
rename to FortranRuntime/lib/Runtime/Float128Math/tan.cpp
index 8f4b723ca977bd..dbe4627f585f14 100644
--- a/flang/runtime/Float128Math/tan.cpp
+++ b/FortranRuntime/lib/Runtime/Float128Math/tan.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/tan.cpp --------------------------------------===//
+//===-- lib/Runtime/Float128Math/tan.cpp ------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/Float128Math/tanh.cpp b/FortranRuntime/lib/Runtime/Float128Math/tanh.cpp
similarity index 87%
rename from flang/runtime/Float128Math/tanh.cpp
rename to FortranRuntime/lib/Runtime/Float128Math/tanh.cpp
index b43a89520b6797..37e40966ced722 100644
--- a/flang/runtime/Float128Math/tanh.cpp
+++ b/FortranRuntime/lib/Runtime/Float128Math/tanh.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/tanh.cpp -------------------------------------===//
+//===-- lib/Runtime/Float128Math/tanh.cpp -----------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/Float128Math/tgamma.cpp b/FortranRuntime/lib/Runtime/Float128Math/tgamma.cpp
similarity index 87%
rename from flang/runtime/Float128Math/tgamma.cpp
rename to FortranRuntime/lib/Runtime/Float128Math/tgamma.cpp
index 93f97800bdc966..07a019c6d9971f 100644
--- a/flang/runtime/Float128Math/tgamma.cpp
+++ b/FortranRuntime/lib/Runtime/Float128Math/tgamma.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/tgamma.cpp -----------------------------------===//
+//===-- lib/Runtime/Float128Math/tgamma.cpp ---------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/Float128Math/trunc.cpp b/FortranRuntime/lib/Runtime/Float128Math/trunc.cpp
similarity index 89%
rename from flang/runtime/Float128Math/trunc.cpp
rename to FortranRuntime/lib/Runtime/Float128Math/trunc.cpp
index ca15a739c030e8..9f38bdc18e73c4 100644
--- a/flang/runtime/Float128Math/trunc.cpp
+++ b/FortranRuntime/lib/Runtime/Float128Math/trunc.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/trunc.cpp ------------------------------------===//
+//===-- lib/Runtime/Float128Math/trunc.cpp ----------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/Float128Math/y0.cpp b/FortranRuntime/lib/Runtime/Float128Math/y0.cpp
similarity index 87%
rename from flang/runtime/Float128Math/y0.cpp
rename to FortranRuntime/lib/Runtime/Float128Math/y0.cpp
index d6f39aac1053a8..6eaa3396e7ea07 100644
--- a/flang/runtime/Float128Math/y0.cpp
+++ b/FortranRuntime/lib/Runtime/Float128Math/y0.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/y0.cpp ---------------------------------------===//
+//===-- lib/Runtime/Float128Math/y0.cpp -------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/Float128Math/y1.cpp b/FortranRuntime/lib/Runtime/Float128Math/y1.cpp
similarity index 87%
rename from flang/runtime/Float128Math/y1.cpp
rename to FortranRuntime/lib/Runtime/Float128Math/y1.cpp
index 477d36a9ea3c66..c9f48ea0e26546 100644
--- a/flang/runtime/Float128Math/y1.cpp
+++ b/FortranRuntime/lib/Runtime/Float128Math/y1.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/y1.cpp ---------------------------------------===//
+//===-- lib/Runtime/Float128Math/y1.cpp -------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/Float128Math/yn.cpp b/FortranRuntime/lib/Runtime/Float128Math/yn.cpp
similarity index 87%
rename from flang/runtime/Float128Math/yn.cpp
rename to FortranRuntime/lib/Runtime/Float128Math/yn.cpp
index 3a040cc8858970..6bc5f4996a88d5 100644
--- a/flang/runtime/Float128Math/yn.cpp
+++ b/FortranRuntime/lib/Runtime/Float128Math/yn.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/yn.cpp ---------------------------------------===//
+//===-- lib/Runtime/Float128Math/yn.cpp -------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/ISO_Fortran_binding.cpp b/FortranRuntime/lib/Runtime/ISO_Fortran_binding.cpp
similarity index 98%
rename from flang/runtime/ISO_Fortran_binding.cpp
rename to FortranRuntime/lib/Runtime/ISO_Fortran_binding.cpp
index fe22026f31f55f..d2fab4bbc30b4d 100644
--- a/flang/runtime/ISO_Fortran_binding.cpp
+++ b/FortranRuntime/lib/Runtime/ISO_Fortran_binding.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/ISO_Fortran_binding.cpp -----------------------------------===//
+//===-- lib/Runtime/ISO_Fortran_binding.cpp ---------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -11,7 +11,7 @@
 
 #include "ISO_Fortran_util.h"
 #include "terminator.h"
-#include "flang/ISO_Fortran_binding_wrapper.h"
+#include "flang/Common/ISO_Fortran_binding_wrapper.h"
 #include "flang/Runtime/descriptor.h"
 #include "flang/Runtime/pointer.h"
 #include "flang/Runtime/type-code.h"
diff --git a/flang/runtime/ISO_Fortran_util.h b/FortranRuntime/lib/Runtime/ISO_Fortran_util.h
similarity index 96%
rename from flang/runtime/ISO_Fortran_util.h
rename to FortranRuntime/lib/Runtime/ISO_Fortran_util.h
index dd0eeef80bb896..c45e8fc7a8d253 100644
--- a/flang/runtime/ISO_Fortran_util.h
+++ b/FortranRuntime/lib/Runtime/ISO_Fortran_util.h
@@ -1,4 +1,4 @@
-//===-- runtime/ISO_Fortran_util.h ------------------------------*- C++ -*-===//
+//===-- lib/Runtime/ISO_Fortran_util.h --------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -12,7 +12,7 @@
 // Internal utils for establishing CFI_cdesc_t descriptors.
 
 #include "terminator.h"
-#include "flang/ISO_Fortran_binding_wrapper.h"
+#include "flang/Common/ISO_Fortran_binding_wrapper.h"
 #include "flang/Runtime/descriptor.h"
 #include "flang/Runtime/type-code.h"
 #include <cstdlib>
diff --git a/flang/runtime/allocatable.cpp b/FortranRuntime/lib/Runtime/allocatable.cpp
similarity index 98%
rename from flang/runtime/allocatable.cpp
rename to FortranRuntime/lib/Runtime/allocatable.cpp
index 5e065f47636a89..e3b43a5f813935 100644
--- a/flang/runtime/allocatable.cpp
+++ b/FortranRuntime/lib/Runtime/allocatable.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/allocatable.cpp -------------------------------------------===//
+//===-- lib/Runtime/allocatable.cpp -----------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -12,7 +12,7 @@
 #include "stat.h"
 #include "terminator.h"
 #include "type-info.h"
-#include "flang/ISO_Fortran_binding_wrapper.h"
+#include "flang/Common/ISO_Fortran_binding_wrapper.h"
 #include "flang/Runtime/assign.h"
 #include "flang/Runtime/descriptor.h"
 
diff --git a/flang/runtime/allocator-registry.cpp b/FortranRuntime/lib/Runtime/allocator-registry.cpp
similarity index 94%
rename from flang/runtime/allocator-registry.cpp
rename to FortranRuntime/lib/Runtime/allocator-registry.cpp
index f5670331d6dbe2..68fb8b80680558 100644
--- a/flang/runtime/allocator-registry.cpp
+++ b/FortranRuntime/lib/Runtime/allocator-registry.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/allocator-registry.cpp ------------------------------------===//
+//===-- lib/Runtime/allocator-registry.cpp ----------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/array-constructor.cpp b/FortranRuntime/lib/Runtime/array-constructor.cpp
similarity index 99%
rename from flang/runtime/array-constructor.cpp
rename to FortranRuntime/lib/Runtime/array-constructor.cpp
index 72e08feff7fd10..287d054887abf0 100644
--- a/flang/runtime/array-constructor.cpp
+++ b/FortranRuntime/lib/Runtime/array-constructor.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/array-constructor.cpp -------------------------------------===//
+//===-- lib/Runtime/array-constructor.cpp -----------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/assign-impl.h b/FortranRuntime/lib/Runtime/assign-impl.h
similarity index 93%
rename from flang/runtime/assign-impl.h
rename to FortranRuntime/lib/Runtime/assign-impl.h
index f07a501d1d1263..6bc8ef78c38a90 100644
--- a/flang/runtime/assign-impl.h
+++ b/FortranRuntime/lib/Runtime/assign-impl.h
@@ -1,4 +1,4 @@
-//===-- runtime/assign-impl.h -----------------------------------*- C++ -*-===//
+//===-- lib/Runtime/assign-impl.h -------------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/assign.cpp b/FortranRuntime/lib/Runtime/assign.cpp
similarity index 99%
rename from flang/runtime/assign.cpp
rename to FortranRuntime/lib/Runtime/assign.cpp
index d558ada51cd21a..7c5eb135d4cfdf 100644
--- a/flang/runtime/assign.cpp
+++ b/FortranRuntime/lib/Runtime/assign.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/assign.cpp ------------------------------------------------===//
+//===-- lib/Runtime/assign.cpp ----------------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/buffer.cpp b/FortranRuntime/lib/Runtime/buffer.cpp
similarity index 92%
rename from flang/runtime/buffer.cpp
rename to FortranRuntime/lib/Runtime/buffer.cpp
index 7b4869d69c2e51..ce78fe34503c46 100644
--- a/flang/runtime/buffer.cpp
+++ b/FortranRuntime/lib/Runtime/buffer.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/buffer.cpp ------------------------------------------------===//
+//===-- lib/Runtime/buffer.cpp ----------------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/buffer.h b/FortranRuntime/lib/Runtime/buffer.h
similarity index 99%
rename from flang/runtime/buffer.h
rename to FortranRuntime/lib/Runtime/buffer.h
index 41a1abb1b2d907..24e43734552e99 100644
--- a/flang/runtime/buffer.h
+++ b/FortranRuntime/lib/Runtime/buffer.h
@@ -1,4 +1,4 @@
-//===-- runtime/buffer.h ----------------------------------------*- C++ -*-===//
+//===-- lib/Runtime/buffer.h ------------------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/character.cpp b/FortranRuntime/lib/Runtime/character.cpp
similarity index 99%
rename from flang/runtime/character.cpp
rename to FortranRuntime/lib/Runtime/character.cpp
index 5049247397eb3c..73d3d93c5015f6 100644
--- a/flang/runtime/character.cpp
+++ b/FortranRuntime/lib/Runtime/character.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/character.cpp ---------------------------------------------===//
+//===-- lib/Runtime/character.cpp -------------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/command.cpp b/FortranRuntime/lib/Runtime/command.cpp
similarity index 98%
rename from flang/runtime/command.cpp
rename to FortranRuntime/lib/Runtime/command.cpp
index a555e26f96a66c..50a084714e69a4 100644
--- a/flang/runtime/command.cpp
+++ b/FortranRuntime/lib/Runtime/command.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/command.cpp -----------------------------------------------===//
+//===-- lib/Runtime/command.cpp ---------------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/complex-powi.cpp b/FortranRuntime/lib/Runtime/complex-powi.cpp
similarity index 91%
rename from flang/runtime/complex-powi.cpp
rename to FortranRuntime/lib/Runtime/complex-powi.cpp
index 77031e40242791..2eacf56386b193 100644
--- a/flang/runtime/complex-powi.cpp
+++ b/FortranRuntime/lib/Runtime/complex-powi.cpp
@@ -1,11 +1,10 @@
-/*===-- flang/runtime/complex-powi.cpp ----------------------------*- C++ -*-===
- *
- * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
- * See https://llvm.org/LICENSE.txt for license information.
- * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
- *
- * ===-----------------------------------------------------------------------===
- */
+//===-- lib/Runtime/complex-powi.cpp ----------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
 #include "flang/Common/float128.h"
 #include "flang/Runtime/entry-names.h"
 #include <cstdint>
diff --git a/flang/runtime/complex-reduction.c b/FortranRuntime/lib/Runtime/complex-reduction.c
similarity index 97%
rename from flang/runtime/complex-reduction.c
rename to FortranRuntime/lib/Runtime/complex-reduction.c
index 37ce3fa410016b..138174e9122b1c 100644
--- a/flang/runtime/complex-reduction.c
+++ b/FortranRuntime/lib/Runtime/complex-reduction.c
@@ -1,11 +1,10 @@
-/*===-- flang/runtime/complex-reduction.c ---------------------------*- C -*-===
+/*===-- lib/Runtime/complex-reduction.c -----------------------------*- C -*-===
  *
  * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  * See https://llvm.org/LICENSE.txt for license information.
  * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  *
- * ===-----------------------------------------------------------------------===
- */
+ *===----------------------------------------------------------------------===*/
 
 #include "complex-reduction.h"
 #include <float.h>
diff --git a/flang/runtime/complex-reduction.h b/FortranRuntime/lib/Runtime/complex-reduction.h
similarity index 97%
rename from flang/runtime/complex-reduction.h
rename to FortranRuntime/lib/Runtime/complex-reduction.h
index b0f19622fdb1a5..1ca5b9a33c4640 100644
--- a/flang/runtime/complex-reduction.h
+++ b/FortranRuntime/lib/Runtime/complex-reduction.h
@@ -1,11 +1,10 @@
-/*===-- flang/runtime/complex-reduction.h ---------------------------*- C -*-===
+/*===-- lib/Runtime/complex-reduction.h -----------------------------*- C -*-===
  *
  * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  * See https://llvm.org/LICENSE.txt for license information.
  * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  *
- * ===-----------------------------------------------------------------------===
- */
+ *===----------------------------------------------------------------------===*/
 
 /* Wraps the C++-coded complex-valued SUM and PRODUCT reductions with
  * C-coded wrapper functions returning _Complex values, to avoid problems
diff --git a/flang/runtime/connection.cpp b/FortranRuntime/lib/Runtime/connection.cpp
similarity index 96%
rename from flang/runtime/connection.cpp
rename to FortranRuntime/lib/Runtime/connection.cpp
index f24f0e832eb484..f9e91f1f193ba0 100644
--- a/flang/runtime/connection.cpp
+++ b/FortranRuntime/lib/Runtime/connection.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/connection.cpp --------------------------------------------===//
+//===-- lib/Runtime/connection.cpp ------------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/connection.h b/FortranRuntime/lib/Runtime/connection.h
similarity index 98%
rename from flang/runtime/connection.h
rename to FortranRuntime/lib/Runtime/connection.h
index 6f1ea90a160e5e..f74e94ff6fb4a3 100644
--- a/flang/runtime/connection.h
+++ b/FortranRuntime/lib/Runtime/connection.h
@@ -1,4 +1,4 @@
-//===-- runtime/connection.h ------------------------------------*- C++ -*-===//
+//===-- lib/Runtime/connection.h --------------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/copy.cpp b/FortranRuntime/lib/Runtime/copy.cpp
similarity index 99%
rename from flang/runtime/copy.cpp
rename to FortranRuntime/lib/Runtime/copy.cpp
index b20f68f019498b..72a86e3b80a7d5 100644
--- a/flang/runtime/copy.cpp
+++ b/FortranRuntime/lib/Runtime/copy.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/copy.cpp -------------------------------------------------===//
+//===-- lib/Runtime/copy.cpp ------------------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/copy.h b/FortranRuntime/lib/Runtime/copy.h
similarity index 93%
rename from flang/runtime/copy.h
rename to FortranRuntime/lib/Runtime/copy.h
index 542660530bfb65..6d37b075e74504 100644
--- a/flang/runtime/copy.h
+++ b/FortranRuntime/lib/Runtime/copy.h
@@ -1,4 +1,4 @@
-//===-- runtime/copy.h ------------------------------------------*- C++ -*-===//
+//===-- lib/Runtime/copy.h --------------------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/derived-api.cpp b/FortranRuntime/lib/Runtime/derived-api.cpp
similarity index 98%
rename from flang/runtime/derived-api.cpp
rename to FortranRuntime/lib/Runtime/derived-api.cpp
index eca784be208d10..0bcdd45ddbbaec 100644
--- a/flang/runtime/derived-api.cpp
+++ b/FortranRuntime/lib/Runtime/derived-api.cpp
@@ -1,5 +1,4 @@
-//===-- runtime/derived-api.cpp
-//-----------------------------------------------===//
+//===-- lib/Runtime/derived-api.cpp -----------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/derived.cpp b/FortranRuntime/lib/Runtime/derived.cpp
similarity index 99%
rename from flang/runtime/derived.cpp
rename to FortranRuntime/lib/Runtime/derived.cpp
index 659f54fa344bb0..04d765211db63b 100644
--- a/flang/runtime/derived.cpp
+++ b/FortranRuntime/lib/Runtime/derived.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/derived.cpp -----------------------------------------------===//
+//===-- lib/Runtime/derived.cpp ---------------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/derived.h b/FortranRuntime/lib/Runtime/derived.h
similarity index 94%
rename from flang/runtime/derived.h
rename to FortranRuntime/lib/Runtime/derived.h
index b4863df8db417c..27c04c7cc56969 100644
--- a/flang/runtime/derived.h
+++ b/FortranRuntime/lib/Runtime/derived.h
@@ -1,4 +1,4 @@
-//===-- runtime/derived.h -------------------------------------------------===//
+//===-- lib/Runtime/derived.h -----------------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/descriptor-io.cpp b/FortranRuntime/lib/Runtime/descriptor-io.cpp
similarity index 98%
rename from flang/runtime/descriptor-io.cpp
rename to FortranRuntime/lib/Runtime/descriptor-io.cpp
index 380ad425d925f0..896fad16a67e8a 100644
--- a/flang/runtime/descriptor-io.cpp
+++ b/FortranRuntime/lib/Runtime/descriptor-io.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/descriptor-io.cpp -----------------------------------------===//
+//===-- lib/Runtime/descriptor-io.cpp ---------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/descriptor-io.h b/FortranRuntime/lib/Runtime/descriptor-io.h
similarity index 99%
rename from flang/runtime/descriptor-io.h
rename to FortranRuntime/lib/Runtime/descriptor-io.h
index ff5f683c6da52f..58cb091f852596 100644
--- a/flang/runtime/descriptor-io.h
+++ b/FortranRuntime/lib/Runtime/descriptor-io.h
@@ -1,4 +1,4 @@
-//===-- runtime/descriptor-io.h ---------------------------------*- C++ -*-===//
+//===-- lib/Runtime/descriptor-io.h -----------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/descriptor.cpp b/FortranRuntime/lib/Runtime/descriptor.cpp
similarity index 99%
rename from flang/runtime/descriptor.cpp
rename to FortranRuntime/lib/Runtime/descriptor.cpp
index 32f43e89dc7a36..f064fe3dcc32e9 100644
--- a/flang/runtime/descriptor.cpp
+++ b/FortranRuntime/lib/Runtime/descriptor.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/descriptor.cpp --------------------------------------------===//
+//===-- lib/Runtime/descriptor.cpp ------------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/dot-product.cpp b/FortranRuntime/lib/Runtime/dot-product.cpp
similarity index 99%
rename from flang/runtime/dot-product.cpp
rename to FortranRuntime/lib/Runtime/dot-product.cpp
index 977698269bcb46..9eb22790e38a69 100644
--- a/flang/runtime/dot-product.cpp
+++ b/FortranRuntime/lib/Runtime/dot-product.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/dot-product.cpp -------------------------------------------===//
+//===-- lib/Runtime/dot-product.cpp -----------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/edit-input.cpp b/FortranRuntime/lib/Runtime/edit-input.cpp
similarity index 99%
rename from flang/runtime/edit-input.cpp
rename to FortranRuntime/lib/Runtime/edit-input.cpp
index 2cee35e23f31a3..6ebb0e7aca4ade 100644
--- a/flang/runtime/edit-input.cpp
+++ b/FortranRuntime/lib/Runtime/edit-input.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/edit-input.cpp --------------------------------------------===//
+//===-- lib/Runtime/edit-input.cpp ------------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/edit-input.h b/FortranRuntime/lib/Runtime/edit-input.h
similarity index 95%
rename from flang/runtime/edit-input.h
rename to FortranRuntime/lib/Runtime/edit-input.h
index a90180b8ee2ebd..96dc3f561c22a7 100644
--- a/flang/runtime/edit-input.h
+++ b/FortranRuntime/lib/Runtime/edit-input.h
@@ -1,4 +1,4 @@
-//===-- runtime/edit-input.h ------------------------------------*- C++ -*-===//
+//===-- lib/Runtime/edit-input.h --------------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -11,7 +11,7 @@
 
 #include "format.h"
 #include "io-stmt.h"
-#include "flang/Decimal/decimal.h"
+#include "flang/Common/decimal.h"
 
 namespace Fortran::runtime::io {
 
diff --git a/flang/runtime/edit-output.cpp b/FortranRuntime/lib/Runtime/edit-output.cpp
similarity index 99%
rename from flang/runtime/edit-output.cpp
rename to FortranRuntime/lib/Runtime/edit-output.cpp
index 9d60732258bfbc..ccaf8085f016fd 100644
--- a/flang/runtime/edit-output.cpp
+++ b/FortranRuntime/lib/Runtime/edit-output.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/edit-output.cpp -------------------------------------------===//
+//===-- lib/Runtime/edit-output.cpp -----------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/edit-output.h b/FortranRuntime/lib/Runtime/edit-output.h
similarity index 98%
rename from flang/runtime/edit-output.h
rename to FortranRuntime/lib/Runtime/edit-output.h
index 365bc2e2a4d10b..7f303020a83a84 100644
--- a/flang/runtime/edit-output.h
+++ b/FortranRuntime/lib/Runtime/edit-output.h
@@ -1,4 +1,4 @@
-//===-- runtime/edit-output.h -----------------------------------*- C++ -*-===//
+//===-- lib/Runtime/edit-output.h -------------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -21,7 +21,7 @@
 #include "format.h"
 #include "io-stmt.h"
 #include "flang/Common/uint128.h"
-#include "flang/Decimal/decimal.h"
+#include "flang/Common/decimal.h"
 
 namespace Fortran::runtime::io {
 
diff --git a/flang/runtime/emit-encoded.h b/FortranRuntime/lib/Runtime/emit-encoded.h
similarity index 98%
rename from flang/runtime/emit-encoded.h
rename to FortranRuntime/lib/Runtime/emit-encoded.h
index 4b5e3900788357..f07fcced488435 100644
--- a/flang/runtime/emit-encoded.h
+++ b/FortranRuntime/lib/Runtime/emit-encoded.h
@@ -1,4 +1,4 @@
-//===-- runtime/emit-encoded.h ----------------------------------*- C++ -*-===//
+//===-- lib/Runtime/emit-encoded.h ------------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/environment-default-list.h b/FortranRuntime/lib/Runtime/environment-default-list.h
old mode 100755
new mode 100644
similarity index 85%
rename from flang/runtime/environment-default-list.h
rename to FortranRuntime/lib/Runtime/environment-default-list.h
index 4da261b10b9a84..6b7542516e7134
--- a/flang/runtime/environment-default-list.h
+++ b/FortranRuntime/lib/Runtime/environment-default-list.h
@@ -1,11 +1,10 @@
-/*===-- runtime/environment-default-list.h --------------------------*- C -*-===
+/*===-- lib/Runtime/environment-default-list.h ----------------------*- C -*-===
  *
  * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  * See https://llvm.org/LICENSE.txt for license information.
  * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  *
- * ===-----------------------------------------------------------------------===
- */
+ *===----------------------------------------------------------------------===*/
 
 #ifndef FORTRAN_RUNTIME_ENVIRONMENT_DEFAULT_LIST_H_
 #define FORTRAN_RUNTIME_ENVIRONMENT_DEFAULT_LIST_H_
diff --git a/flang/runtime/environment.cpp b/FortranRuntime/lib/Runtime/environment.cpp
similarity index 98%
rename from flang/runtime/environment.cpp
rename to FortranRuntime/lib/Runtime/environment.cpp
index 52b1d99ba536ed..272914877988a5 100644
--- a/flang/runtime/environment.cpp
+++ b/FortranRuntime/lib/Runtime/environment.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/environment.cpp -------------------------------------------===//
+//===-- lib/Runtime/environment.cpp -----------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/environment.h b/FortranRuntime/lib/Runtime/environment.h
similarity index 95%
rename from flang/runtime/environment.h
rename to FortranRuntime/lib/Runtime/environment.h
index b8b9f10e4e57f5..71526d2b85d74c 100644
--- a/flang/runtime/environment.h
+++ b/FortranRuntime/lib/Runtime/environment.h
@@ -1,4 +1,4 @@
-//===-- runtime/environment.h -----------------------------------*- C++ -*-===//
+//===-- lib/Runtime/environment.h -------------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -10,7 +10,7 @@
 #define FORTRAN_RUNTIME_ENVIRONMENT_H_
 
 #include "flang/Common/optional.h"
-#include "flang/Decimal/decimal.h"
+#include "flang/Common/decimal.h"
 
 struct EnvironmentDefaultList;
 
diff --git a/flang/runtime/exceptions.cpp b/FortranRuntime/lib/Runtime/exceptions.cpp
similarity index 96%
rename from flang/runtime/exceptions.cpp
rename to FortranRuntime/lib/Runtime/exceptions.cpp
index 8239c556bcea97..7739130ae2346a 100644
--- a/flang/runtime/exceptions.cpp
+++ b/FortranRuntime/lib/Runtime/exceptions.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/exceptions.cpp --------------------------------------===//
+//===-- lib/Runtime/exceptions.cpp ------------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/execute.cpp b/FortranRuntime/lib/Runtime/execute.cpp
similarity index 99%
rename from flang/runtime/execute.cpp
rename to FortranRuntime/lib/Runtime/execute.cpp
index c7f8f386d81f4f..77aac164242612 100644
--- a/flang/runtime/execute.cpp
+++ b/FortranRuntime/lib/Runtime/execute.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/execute.cpp -----------------------------------------------===//
+//===-- lib/Runtime/execute.cpp ---------------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/extensions.cpp b/FortranRuntime/lib/Runtime/extensions.cpp
similarity index 98%
rename from flang/runtime/extensions.cpp
rename to FortranRuntime/lib/Runtime/extensions.cpp
index be3833db88b07a..e75fa75893a82b 100644
--- a/flang/runtime/extensions.cpp
+++ b/FortranRuntime/lib/Runtime/extensions.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/extensions.cpp --------------------------------------------===//
+//===-- lib/Runtime/extensions.cpp ------------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/external-unit.cpp b/FortranRuntime/lib/Runtime/external-unit.cpp
similarity index 99%
rename from flang/runtime/external-unit.cpp
rename to FortranRuntime/lib/Runtime/external-unit.cpp
index d17a92622f8448..f5fa2c31dafc4e 100644
--- a/flang/runtime/external-unit.cpp
+++ b/FortranRuntime/lib/Runtime/external-unit.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/external-unit.cpp -----------------------------------------===//
+//===-- lib/Runtime/external-unit.cpp ---------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/extrema.cpp b/FortranRuntime/lib/Runtime/extrema.cpp
similarity index 99%
rename from flang/runtime/extrema.cpp
rename to FortranRuntime/lib/Runtime/extrema.cpp
index d6e9633372f524..be9da63d7bd6b8 100644
--- a/flang/runtime/extrema.cpp
+++ b/FortranRuntime/lib/Runtime/extrema.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/extrema.cpp -----------------------------------------------===//
+//===-- lib/Runtime/extrema.cpp ---------------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/file.cpp b/FortranRuntime/lib/Runtime/file.cpp
similarity index 99%
rename from flang/runtime/file.cpp
rename to FortranRuntime/lib/Runtime/file.cpp
index ec772903242b80..44e3850cdfcb13 100644
--- a/flang/runtime/file.cpp
+++ b/FortranRuntime/lib/Runtime/file.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/file.cpp --------------------------------------------------===//
+//===-- lib/Runtime/file.cpp ------------------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/file.h b/FortranRuntime/lib/Runtime/file.h
similarity index 98%
rename from flang/runtime/file.h
rename to FortranRuntime/lib/Runtime/file.h
index c06acbb9904cc1..6890cb62d66652 100644
--- a/flang/runtime/file.h
+++ b/FortranRuntime/lib/Runtime/file.h
@@ -1,4 +1,4 @@
-//===-- runtime/file.h ------------------------------------------*- C++ -*-===//
+//===-- lib/Runtime/file.h --------------------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/findloc.cpp b/FortranRuntime/lib/Runtime/findloc.cpp
similarity index 99%
rename from flang/runtime/findloc.cpp
rename to FortranRuntime/lib/Runtime/findloc.cpp
index 674a21ae50b853..da5fe0c0a0a467 100644
--- a/flang/runtime/findloc.cpp
+++ b/FortranRuntime/lib/Runtime/findloc.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/findloc.cpp -----------------------------------------------===//
+//===-- lib/Runtime/findloc.cpp ---------------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/format-implementation.h b/FortranRuntime/lib/Runtime/format-implementation.h
similarity index 99%
rename from flang/runtime/format-implementation.h
rename to FortranRuntime/lib/Runtime/format-implementation.h
index 46204ca927c135..2ed6006c3b2fa0 100644
--- a/flang/runtime/format-implementation.h
+++ b/FortranRuntime/lib/Runtime/format-implementation.h
@@ -1,4 +1,4 @@
-//===-- runtime/format-implementation.h -------------------------*- C++ -*-===//
+//===-- lib/Runtime/format-implementation.h ---------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -16,7 +16,7 @@
 #include "io-stmt.h"
 #include "memory.h"
 #include "flang/Common/format.h"
-#include "flang/Decimal/decimal.h"
+#include "flang/Common/decimal.h"
 #include "flang/Runtime/main.h"
 #include <algorithm>
 #include <cstring>
diff --git a/flang/runtime/format.cpp b/FortranRuntime/lib/Runtime/format.cpp
similarity index 92%
rename from flang/runtime/format.cpp
rename to FortranRuntime/lib/Runtime/format.cpp
index 433acce4b73739..73a61f785c23b8 100644
--- a/flang/runtime/format.cpp
+++ b/FortranRuntime/lib/Runtime/format.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/format.cpp ------------------------------------------------===//
+//===-- lib/Runtime/format.cpp ----------------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/format.h b/FortranRuntime/lib/Runtime/format.h
similarity index 98%
rename from flang/runtime/format.h
rename to FortranRuntime/lib/Runtime/format.h
index 5329f2482d3e46..b9c6979d1c2c98 100644
--- a/flang/runtime/format.h
+++ b/FortranRuntime/lib/Runtime/format.h
@@ -1,4 +1,4 @@
-//===-- runtime/format.h ----------------------------------------*- C++ -*-===//
+//===-- lib/Runtime/format.h ------------------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -13,9 +13,9 @@
 
 #include "environment.h"
 #include "io-error.h"
-#include "flang/Common/Fortran.h"
+#include "flang/Common/Fortran-consts.h"
 #include "flang/Common/optional.h"
-#include "flang/Decimal/decimal.h"
+#include "flang/Common/decimal.h"
 #include "flang/Runtime/freestanding-tools.h"
 #include <cinttypes>
 
diff --git a/flang/runtime/inquiry.cpp b/FortranRuntime/lib/Runtime/inquiry.cpp
similarity index 97%
rename from flang/runtime/inquiry.cpp
rename to FortranRuntime/lib/Runtime/inquiry.cpp
index 9fbcaa96fa3c43..9a5ef0cea210db 100644
--- a/flang/runtime/inquiry.cpp
+++ b/FortranRuntime/lib/Runtime/inquiry.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/inquiry.cpp --------------------------------------===//
+//===-- lib/Runtime/inquiry.cpp ---------------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/internal-unit.cpp b/FortranRuntime/lib/Runtime/internal-unit.cpp
similarity index 98%
rename from flang/runtime/internal-unit.cpp
rename to FortranRuntime/lib/Runtime/internal-unit.cpp
index f28700ee015815..95d371a49ac187 100644
--- a/flang/runtime/internal-unit.cpp
+++ b/FortranRuntime/lib/Runtime/internal-unit.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/internal-unit.cpp -----------------------------------------===//
+//===-- lib/Runtime/internal-unit.cpp ---------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/internal-unit.h b/FortranRuntime/lib/Runtime/internal-unit.h
similarity index 97%
rename from flang/runtime/internal-unit.h
rename to FortranRuntime/lib/Runtime/internal-unit.h
index a0ee6353eeda3b..444bc9ab515994 100644
--- a/flang/runtime/internal-unit.h
+++ b/FortranRuntime/lib/Runtime/internal-unit.h
@@ -1,4 +1,4 @@
-//===-- runtime/internal-unit.h ---------------------------------*- C++ -*-===//
+//===-- lib/Runtime/internal-unit.h -----------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/io-api-common.h b/FortranRuntime/lib/Runtime/io-api-common.h
similarity index 98%
rename from flang/runtime/io-api-common.h
rename to FortranRuntime/lib/Runtime/io-api-common.h
index c7b86cab73a525..9b4c3405b0991e 100644
--- a/flang/runtime/io-api-common.h
+++ b/FortranRuntime/lib/Runtime/io-api-common.h
@@ -1,4 +1,4 @@
-//===-- runtime/io-api-common.h ---------------------------------*- C++ -*-===//
+//===-- lib/Runtime/io-api-common.h -----------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/io-api-minimal.cpp b/FortranRuntime/lib/Runtime/io-api-minimal.cpp
similarity index 98%
rename from flang/runtime/io-api-minimal.cpp
rename to FortranRuntime/lib/Runtime/io-api-minimal.cpp
index ad76fe3de0324c..6bc262cae78458 100644
--- a/flang/runtime/io-api-minimal.cpp
+++ b/FortranRuntime/lib/Runtime/io-api-minimal.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/io-api-minimal.cpp ----------------------------------------===//
+//===-- lib/Runtime/io-api-minimal.cpp --------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/io-api.cpp b/FortranRuntime/lib/Runtime/io-api.cpp
similarity index 99%
rename from flang/runtime/io-api.cpp
rename to FortranRuntime/lib/Runtime/io-api.cpp
index e3c6b9e5ca8959..f4a396d4c49a45 100644
--- a/flang/runtime/io-api.cpp
+++ b/FortranRuntime/lib/Runtime/io-api.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/io-api.cpp ------------------------------------------------===//
+//===-- lib/Runtime/io-api.cpp ----------------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/io-error.cpp b/FortranRuntime/lib/Runtime/io-error.cpp
similarity index 98%
rename from flang/runtime/io-error.cpp
rename to FortranRuntime/lib/Runtime/io-error.cpp
index 7a90966f81047f..053667462058de 100644
--- a/flang/runtime/io-error.cpp
+++ b/FortranRuntime/lib/Runtime/io-error.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/io-error.cpp ----------------------------------------------===//
+//===-- lib/Runtime/io-error.cpp --------------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/io-error.h b/FortranRuntime/lib/Runtime/io-error.h
similarity index 97%
rename from flang/runtime/io-error.h
rename to FortranRuntime/lib/Runtime/io-error.h
index 426573e2faf00c..b03e07567a0607 100644
--- a/flang/runtime/io-error.h
+++ b/FortranRuntime/lib/Runtime/io-error.h
@@ -1,4 +1,4 @@
-//===-- runtime/io-error.h --------------------------------------*- C++ -*-===//
+//===-- lib/Runtime/io-error.h ----------------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/io-stmt.cpp b/FortranRuntime/lib/Runtime/io-stmt.cpp
similarity index 99%
rename from flang/runtime/io-stmt.cpp
rename to FortranRuntime/lib/Runtime/io-stmt.cpp
index 265bd0dc9d9499..80c96710eb49ca 100644
--- a/flang/runtime/io-stmt.cpp
+++ b/FortranRuntime/lib/Runtime/io-stmt.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/io-stmt.cpp -----------------------------------------------===//
+//===-- lib/Runtime/io-stmt.cpp ---------------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/io-stmt.h b/FortranRuntime/lib/Runtime/io-stmt.h
similarity index 99%
rename from flang/runtime/io-stmt.h
rename to FortranRuntime/lib/Runtime/io-stmt.h
index 2e0ca46078ecdc..e90e64c8fd1ff3 100644
--- a/flang/runtime/io-stmt.h
+++ b/FortranRuntime/lib/Runtime/io-stmt.h
@@ -1,4 +1,4 @@
-//===-- runtime/io-stmt.h ---------------------------------------*- C++ -*-===//
+//===-- lib/Runtime/io-stmt.h -----------------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/iostat.cpp b/FortranRuntime/lib/Runtime/iostat.cpp
similarity index 98%
rename from flang/runtime/iostat.cpp
rename to FortranRuntime/lib/Runtime/iostat.cpp
index 39e224cb01286b..f23567be4910da 100644
--- a/flang/runtime/iostat.cpp
+++ b/FortranRuntime/lib/Runtime/iostat.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/iostat.cpp ------------------------------------------------===//
+//===-- lib/Runtime/iostat.cpp ----------------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/module/iso_fortran_env_impl.f90 b/FortranRuntime/lib/Runtime/iso_fortran_env_impl.f90
similarity index 98%
rename from flang/module/iso_fortran_env_impl.f90
rename to FortranRuntime/lib/Runtime/iso_fortran_env_impl.f90
index 4de54dda7bab1c..1a4da69266c55b 100644
--- a/flang/module/iso_fortran_env_impl.f90
+++ b/FortranRuntime/lib/Runtime/iso_fortran_env_impl.f90
@@ -1,4 +1,4 @@
-!===-- module/iso_fortran_env_impl.f90 --=--------------------------------===!
+!===-- lib/Runtime/iso_fortran_env_impl.f90 --------------------------------===!
 !
 ! Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 ! See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/lock.h b/FortranRuntime/lib/Runtime/lock.h
similarity index 97%
rename from flang/runtime/lock.h
rename to FortranRuntime/lib/Runtime/lock.h
index 46ca28703a45b4..75c1adb12a8c62 100644
--- a/flang/runtime/lock.h
+++ b/FortranRuntime/lib/Runtime/lock.h
@@ -1,4 +1,4 @@
-//===-- runtime/lock.h ------------------------------------------*- C++ -*-===//
+//===-- lib/Runtime/lock.h --------------------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/main.cpp b/FortranRuntime/lib/Runtime/main.cpp
similarity index 94%
rename from flang/runtime/main.cpp
rename to FortranRuntime/lib/Runtime/main.cpp
index 96454989581b71..3fe985e524548d 100644
--- a/flang/runtime/main.cpp
+++ b/FortranRuntime/lib/Runtime/main.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/main.cpp --------------------------------------------------===//
+//===-- lib/Runtime/main.cpp ------------------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/matmul-transpose.cpp b/FortranRuntime/lib/Runtime/matmul-transpose.cpp
similarity index 99%
rename from flang/runtime/matmul-transpose.cpp
rename to FortranRuntime/lib/Runtime/matmul-transpose.cpp
index 283472650a1c69..d493333dfa9877 100644
--- a/flang/runtime/matmul-transpose.cpp
+++ b/FortranRuntime/lib/Runtime/matmul-transpose.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/matmul-transpose.cpp --------------------------------------===//
+//===-- lib/Runtime/matmul-transpose.cpp ------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/matmul.cpp b/FortranRuntime/lib/Runtime/matmul.cpp
similarity index 99%
rename from flang/runtime/matmul.cpp
rename to FortranRuntime/lib/Runtime/matmul.cpp
index 252557e2f9e7ad..124369e72886c5 100644
--- a/flang/runtime/matmul.cpp
+++ b/FortranRuntime/lib/Runtime/matmul.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/matmul.cpp ------------------------------------------------===//
+//===-- lib/Runtime/matmul.cpp ----------------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/memory.cpp b/FortranRuntime/lib/Runtime/memory.cpp
similarity index 93%
rename from flang/runtime/memory.cpp
rename to FortranRuntime/lib/Runtime/memory.cpp
index c7068ad6479a12..4a811107ca220a 100644
--- a/flang/runtime/memory.cpp
+++ b/FortranRuntime/lib/Runtime/memory.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/memory.cpp ------------------------------------------------===//
+//===-- lib/Runtime/memory.cpp ----------------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/misc-intrinsic.cpp b/FortranRuntime/lib/Runtime/misc-intrinsic.cpp
similarity index 98%
rename from flang/runtime/misc-intrinsic.cpp
rename to FortranRuntime/lib/Runtime/misc-intrinsic.cpp
index f7d893829fc0d3..b942d762e76ab3 100644
--- a/flang/runtime/misc-intrinsic.cpp
+++ b/FortranRuntime/lib/Runtime/misc-intrinsic.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/misc-intrinsic.cpp ----------------------------------------===//
+//===-- lib/Runtime/misc-intrinsic.cpp --------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/namelist.cpp b/FortranRuntime/lib/Runtime/namelist.cpp
similarity index 99%
rename from flang/runtime/namelist.cpp
rename to FortranRuntime/lib/Runtime/namelist.cpp
index af092de70f7819..e6229d56577568 100644
--- a/flang/runtime/namelist.cpp
+++ b/FortranRuntime/lib/Runtime/namelist.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/namelist.cpp ----------------------------------------------===//
+//===-- lib/Runtime/namelist.cpp --------------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/namelist.h b/FortranRuntime/lib/Runtime/namelist.h
similarity index 96%
rename from flang/runtime/namelist.h
rename to FortranRuntime/lib/Runtime/namelist.h
index 25216a75e9367d..4694b3104a9c75 100644
--- a/flang/runtime/namelist.h
+++ b/FortranRuntime/lib/Runtime/namelist.h
@@ -1,4 +1,4 @@
-//===-- runtime/namelist.h --------------------------------------*- C++ -*-===//
+//===-- lib/Runtime/namelist.h ----------------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/non-tbp-dio.cpp b/FortranRuntime/lib/Runtime/non-tbp-dio.cpp
similarity index 93%
rename from flang/runtime/non-tbp-dio.cpp
rename to FortranRuntime/lib/Runtime/non-tbp-dio.cpp
index 9419adb7631cc9..9fa04397bc9610 100644
--- a/flang/runtime/non-tbp-dio.cpp
+++ b/FortranRuntime/lib/Runtime/non-tbp-dio.cpp
@@ -1,4 +1,4 @@
-//===-- flang/runtime/non-tbp-dio.cpp ---------------------------*- C++ -*-===//
+//===-- lib/Runtime/non-tbp-dio.cpp -----------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/non-tbp-dio.h b/FortranRuntime/lib/Runtime/non-tbp-dio.h
similarity index 93%
rename from flang/runtime/non-tbp-dio.h
rename to FortranRuntime/lib/Runtime/non-tbp-dio.h
index 05038a264ed992..0a45c96a3f2e25 100644
--- a/flang/runtime/non-tbp-dio.h
+++ b/FortranRuntime/lib/Runtime/non-tbp-dio.h
@@ -1,4 +1,4 @@
-//===-- flang/runtime/non-tbp-dio.h -----------------------------*- C++ -*-===//
+//===-- lib/Runtime/non-tbp-dio.h -------------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -22,7 +22,8 @@
 #ifndef FORTRAN_RUNTIME_NON_TBP_DIO_H_
 #define FORTRAN_RUNTIME_NON_TBP_DIO_H_
 
-#include "flang/Common/Fortran.h"
+#include "flang/Common/Fortran-consts.h"
+#include "flang/Common/api-attrs.h"
 #include <cstddef>
 
 namespace Fortran::runtime::typeInfo {
diff --git a/flang/runtime/numeric-templates.h b/FortranRuntime/lib/Runtime/numeric-templates.h
similarity index 99%
rename from flang/runtime/numeric-templates.h
rename to FortranRuntime/lib/Runtime/numeric-templates.h
index 1b43498a6bfd12..640c6d17c4b580 100644
--- a/flang/runtime/numeric-templates.h
+++ b/FortranRuntime/lib/Runtime/numeric-templates.h
@@ -1,4 +1,4 @@
-//===-- runtime/numeric-templates.h -----------------------------*- C++ -*-===//
+//===-- lib/Runtime/numeric-templates.h -------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/numeric.cpp b/FortranRuntime/lib/Runtime/numeric.cpp
similarity index 99%
rename from flang/runtime/numeric.cpp
rename to FortranRuntime/lib/Runtime/numeric.cpp
index 9a8ddc6615564d..b0f68a7fc81d29 100644
--- a/flang/runtime/numeric.cpp
+++ b/FortranRuntime/lib/Runtime/numeric.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/numeric.cpp -----------------------------------------------===//
+//===-- lib/Runtime/numeric.cpp ---------------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/pointer.cpp b/FortranRuntime/lib/Runtime/pointer.cpp
similarity index 99%
rename from flang/runtime/pointer.cpp
rename to FortranRuntime/lib/Runtime/pointer.cpp
index 2979181ddd61bd..fba9e639fa37a8 100644
--- a/flang/runtime/pointer.cpp
+++ b/FortranRuntime/lib/Runtime/pointer.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/pointer.cpp -----------------------------------------------===//
+//===-- lib/Runtime/pointer.cpp ---------------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/product.cpp b/FortranRuntime/lib/Runtime/product.cpp
similarity index 98%
rename from flang/runtime/product.cpp
rename to FortranRuntime/lib/Runtime/product.cpp
index 7fc0fcd3b107de..e4a6e81bd0c508 100644
--- a/flang/runtime/product.cpp
+++ b/FortranRuntime/lib/Runtime/product.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/product.cpp -----------------------------------------------===//
+//===-- lib/Runtime/product.cpp ---------------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/pseudo-unit.cpp b/FortranRuntime/lib/Runtime/pseudo-unit.cpp
similarity index 98%
rename from flang/runtime/pseudo-unit.cpp
rename to FortranRuntime/lib/Runtime/pseudo-unit.cpp
index 526afd11d916e9..62c6b1df5071c7 100644
--- a/flang/runtime/pseudo-unit.cpp
+++ b/FortranRuntime/lib/Runtime/pseudo-unit.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/pseudo-unit.cpp -------------------------------------------===//
+//===-- lib/Runtime/pseudo-unit.cpp -----------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/ragged.cpp b/FortranRuntime/lib/Runtime/ragged.cpp
similarity index 97%
rename from flang/runtime/ragged.cpp
rename to FortranRuntime/lib/Runtime/ragged.cpp
index a4d9e541ba5311..681a800e29dca7 100644
--- a/flang/runtime/ragged.cpp
+++ b/FortranRuntime/lib/Runtime/ragged.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/ragged.cpp ------------------------------------------------===//
+//===-- lib/Runtime/ragged.cpp ----------------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/random-templates.h b/FortranRuntime/lib/Runtime/random-templates.h
similarity index 97%
rename from flang/runtime/random-templates.h
rename to FortranRuntime/lib/Runtime/random-templates.h
index f34422f6f5d9ac..4faca63ba34b9d 100644
--- a/flang/runtime/random-templates.h
+++ b/FortranRuntime/lib/Runtime/random-templates.h
@@ -1,4 +1,4 @@
-//===-- runtime/random-templates.h ------------------------------*- C++ -*-===//
+//===-- lib/Runtime/random-templates.h --------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/random.cpp b/FortranRuntime/lib/Runtime/random.cpp
similarity index 98%
rename from flang/runtime/random.cpp
rename to FortranRuntime/lib/Runtime/random.cpp
index 69de9b8c96fb5d..343b0a389fcaf6 100644
--- a/flang/runtime/random.cpp
+++ b/FortranRuntime/lib/Runtime/random.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/random.cpp ------------------------------------------------===//
+//===-- lib/Runtime/random.cpp ----------------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/reduce.cpp b/FortranRuntime/lib/Runtime/reduce.cpp
similarity index 99%
rename from flang/runtime/reduce.cpp
rename to FortranRuntime/lib/Runtime/reduce.cpp
index 2f4bb6ea159cf4..c3e7ef74363431 100644
--- a/flang/runtime/reduce.cpp
+++ b/FortranRuntime/lib/Runtime/reduce.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/reduce.cpp ------------------------------------------------===//
+//===-- lib/Runtime/reduce.cpp ----------------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/reduction-templates.h b/FortranRuntime/lib/Runtime/reduction-templates.h
similarity index 99%
rename from flang/runtime/reduction-templates.h
rename to FortranRuntime/lib/Runtime/reduction-templates.h
index a51404c9637620..ba193a9f0e3b9d 100644
--- a/flang/runtime/reduction-templates.h
+++ b/FortranRuntime/lib/Runtime/reduction-templates.h
@@ -1,4 +1,4 @@
-//===-- runtime/reduction-templates.h ---------------------------*- C++ -*-===//
+//===-- lib/Runtime/reduction-templates.h -----------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/reduction.cpp b/FortranRuntime/lib/Runtime/reduction.cpp
similarity index 99%
rename from flang/runtime/reduction.cpp
rename to FortranRuntime/lib/Runtime/reduction.cpp
index 074a270cb50838..0de7dd07b17a5b 100644
--- a/flang/runtime/reduction.cpp
+++ b/FortranRuntime/lib/Runtime/reduction.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/reduction.cpp ---------------------------------------------===//
+//===-- lib/Runtime/reduction.cpp -------------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/stack.h b/FortranRuntime/lib/Runtime/stack.h
similarity index 98%
rename from flang/runtime/stack.h
rename to FortranRuntime/lib/Runtime/stack.h
index b6e6edb595e9ad..974ccb9d30b0eb 100644
--- a/flang/runtime/stack.h
+++ b/FortranRuntime/lib/Runtime/stack.h
@@ -1,4 +1,4 @@
-//===-- runtime/stack.h -----------------------------------------*- C++ -*-===//
+//===-- lib/Runtime/stack.h -------------------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/stat.cpp b/FortranRuntime/lib/Runtime/stat.cpp
similarity index 97%
rename from flang/runtime/stat.cpp
rename to FortranRuntime/lib/Runtime/stat.cpp
index 525a4e36cdc773..d483f75998a746 100644
--- a/flang/runtime/stat.cpp
+++ b/FortranRuntime/lib/Runtime/stat.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/stat.cpp --------------------------------------------------===//
+//===-- lib/Runtime/stat.cpp ------------------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/stat.h b/FortranRuntime/lib/Runtime/stat.h
similarity index 95%
rename from flang/runtime/stat.h
rename to FortranRuntime/lib/Runtime/stat.h
index 71faeb027d9085..9f56d88f588a1e 100644
--- a/flang/runtime/stat.h
+++ b/FortranRuntime/lib/Runtime/stat.h
@@ -1,4 +1,4 @@
-//===-- runtime/stat.h ------------------------------------------*- C++ -*-===//
+//===-- lib/Runtime/stat.h --------------------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -12,7 +12,7 @@
 #ifndef FORTRAN_RUNTIME_STAT_H_
 #define FORTRAN_RUNTIME_STAT_H_
 #include "flang/Common/api-attrs.h"
-#include "flang/ISO_Fortran_binding_wrapper.h"
+#include "flang/Common/ISO_Fortran_binding_wrapper.h"
 #include "flang/Runtime/magic-numbers.h"
 namespace Fortran::runtime {
 
diff --git a/flang/runtime/stop.cpp b/FortranRuntime/lib/Runtime/stop.cpp
similarity index 98%
rename from flang/runtime/stop.cpp
rename to FortranRuntime/lib/Runtime/stop.cpp
index cfb36b40840200..8465a53168e551 100644
--- a/flang/runtime/stop.cpp
+++ b/FortranRuntime/lib/Runtime/stop.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/stop.cpp --------------------------------------------------===//
+//===-- lib/Runtime/stop.cpp ------------------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/sum.cpp b/FortranRuntime/lib/Runtime/sum.cpp
similarity index 98%
rename from flang/runtime/sum.cpp
rename to FortranRuntime/lib/Runtime/sum.cpp
index 63d8c9029a0ef5..64982b9fd53690 100644
--- a/flang/runtime/sum.cpp
+++ b/FortranRuntime/lib/Runtime/sum.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/sum.cpp ---------------------------------------------------===//
+//===-- lib/Runtime/sum.cpp -------------------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/support.cpp b/FortranRuntime/lib/Runtime/support.cpp
similarity index 94%
rename from flang/runtime/support.cpp
rename to FortranRuntime/lib/Runtime/support.cpp
index a607120256d9d9..1dffa99191bae1 100644
--- a/flang/runtime/support.cpp
+++ b/FortranRuntime/lib/Runtime/support.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/support.cpp -----------------------------------------------===//
+//===-- lib/Runtime/support.cpp ---------------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/temporary-stack.cpp b/FortranRuntime/lib/Runtime/temporary-stack.cpp
similarity index 98%
rename from flang/runtime/temporary-stack.cpp
rename to FortranRuntime/lib/Runtime/temporary-stack.cpp
index 667b10e04dbd29..12fa18586b7421 100644
--- a/flang/runtime/temporary-stack.cpp
+++ b/FortranRuntime/lib/Runtime/temporary-stack.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/temporary-stack.cpp ---------------------------------------===//
+//===-- lib/Runtime/temporary-stack.cpp -------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -11,7 +11,7 @@
 
 #include "flang/Runtime/temporary-stack.h"
 #include "terminator.h"
-#include "flang/ISO_Fortran_binding_wrapper.h"
+#include "flang/Common/ISO_Fortran_binding_wrapper.h"
 #include "flang/Runtime/assign.h"
 #include "flang/Runtime/descriptor.h"
 #include "flang/Runtime/memory.h"
diff --git a/flang/runtime/terminator.cpp b/FortranRuntime/lib/Runtime/terminator.cpp
similarity index 97%
rename from flang/runtime/terminator.cpp
rename to FortranRuntime/lib/Runtime/terminator.cpp
index bab9edc64fa35b..4146e28235511f 100644
--- a/flang/runtime/terminator.cpp
+++ b/FortranRuntime/lib/Runtime/terminator.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/terminate.cpp ---------------------------------------------===//
+//===-- lib/Runtime/terminator.cpp ------------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/terminator.h b/FortranRuntime/lib/Runtime/terminator.h
similarity index 98%
rename from flang/runtime/terminator.h
rename to FortranRuntime/lib/Runtime/terminator.h
index 609f059d6e0921..02b3a4c4f066f8 100644
--- a/flang/runtime/terminator.h
+++ b/FortranRuntime/lib/Runtime/terminator.h
@@ -1,4 +1,4 @@
-//===-- runtime/terminator.h ------------------------------------*- C++ -*-===//
+//===-- lib/Runtime/terminator.h --------------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/time-intrinsic.cpp b/FortranRuntime/lib/Runtime/time-intrinsic.cpp
similarity index 99%
rename from flang/runtime/time-intrinsic.cpp
rename to FortranRuntime/lib/Runtime/time-intrinsic.cpp
index e6f6e81c7b50cc..05f7e4f80f18b6 100644
--- a/flang/runtime/time-intrinsic.cpp
+++ b/FortranRuntime/lib/Runtime/time-intrinsic.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/time-intrinsic.cpp ----------------------------------------===//
+//===-- lib/Runtime/time-intrinsic.cpp --------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/tools.cpp b/FortranRuntime/lib/Runtime/tools.cpp
similarity index 99%
rename from flang/runtime/tools.cpp
rename to FortranRuntime/lib/Runtime/tools.cpp
index 73d6c2cf7e1d2b..d5c113a31fc501 100644
--- a/flang/runtime/tools.cpp
+++ b/FortranRuntime/lib/Runtime/tools.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/tools.cpp -------------------------------------------------===//
+//===-- lib/Runtime/tools.cpp -----------------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/tools.h b/FortranRuntime/lib/Runtime/tools.h
similarity index 99%
rename from flang/runtime/tools.h
rename to FortranRuntime/lib/Runtime/tools.h
index dc12e5c4533e2e..b57c7996135913 100644
--- a/flang/runtime/tools.h
+++ b/FortranRuntime/lib/Runtime/tools.h
@@ -1,4 +1,4 @@
-//===-- runtime/tools.h -----------------------------------------*- C++ -*-===//
+//===-- lib/Runtime/tools.h -------------------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/transformational.cpp b/FortranRuntime/lib/Runtime/transformational.cpp
similarity index 99%
rename from flang/runtime/transformational.cpp
rename to FortranRuntime/lib/Runtime/transformational.cpp
index b6b204be4418c9..8c244fc296f3b9 100644
--- a/flang/runtime/transformational.cpp
+++ b/FortranRuntime/lib/Runtime/transformational.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/transformational.cpp --------------------------------------===//
+//===-- lib/Runtime/transformational.cpp ------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/type-code.cpp b/FortranRuntime/lib/Runtime/type-code.cpp
similarity index 98%
rename from flang/runtime/type-code.cpp
rename to FortranRuntime/lib/Runtime/type-code.cpp
index cb1b944433aae5..2709ca1be75a53 100644
--- a/flang/runtime/type-code.cpp
+++ b/FortranRuntime/lib/Runtime/type-code.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/type-code.cpp ---------------------------------------------===//
+//===-- lib/Runtime/type-code.cpp -------------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -7,6 +7,7 @@
 //===----------------------------------------------------------------------===//
 
 #include "flang/Runtime/type-code.h"
+#include <cstdint>
 
 namespace Fortran::runtime {
 
diff --git a/flang/runtime/type-info.cpp b/FortranRuntime/lib/Runtime/type-info.cpp
similarity index 99%
rename from flang/runtime/type-info.cpp
rename to FortranRuntime/lib/Runtime/type-info.cpp
index cb18c5669b5ffc..24fc9c33d92819 100644
--- a/flang/runtime/type-info.cpp
+++ b/FortranRuntime/lib/Runtime/type-info.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/type-info.cpp ---------------------------------------------===//
+//===-- lib/Runtime/type-info.cpp -------------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/type-info.h b/FortranRuntime/lib/Runtime/type-info.h
similarity index 99%
rename from flang/runtime/type-info.h
rename to FortranRuntime/lib/Runtime/type-info.h
index c3f3595e32ef28..28e7c4696613b3 100644
--- a/flang/runtime/type-info.h
+++ b/FortranRuntime/lib/Runtime/type-info.h
@@ -1,4 +1,4 @@
-//===-- runtime/type-info.h -------------------------------------*- C++ -*-===//
+//===-- lib/Runtime/type-info.h ---------------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -13,7 +13,7 @@
 // flang/module/__fortran_type_info.f90.
 
 #include "terminator.h"
-#include "flang/Common/Fortran.h"
+#include "flang/Common/Fortran-consts.h"
 #include "flang/Common/bit-population-count.h"
 #include "flang/Common/optional.h"
 #include "flang/Runtime/descriptor.h"
diff --git a/flang/runtime/unit-map.cpp b/FortranRuntime/lib/Runtime/unit-map.cpp
similarity index 97%
rename from flang/runtime/unit-map.cpp
rename to FortranRuntime/lib/Runtime/unit-map.cpp
index 684a9b9e20b97a..93958be8df7ea5 100644
--- a/flang/runtime/unit-map.cpp
+++ b/FortranRuntime/lib/Runtime/unit-map.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/unit-map.cpp ----------------------------------------------===//
+//===-- lib/Runtime/unit-map.cpp --------------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/unit-map.h b/FortranRuntime/lib/Runtime/unit-map.h
similarity index 97%
rename from flang/runtime/unit-map.h
rename to FortranRuntime/lib/Runtime/unit-map.h
index 6f1e01bb1e64ac..f9f0d34d4f0193 100644
--- a/flang/runtime/unit-map.h
+++ b/FortranRuntime/lib/Runtime/unit-map.h
@@ -1,4 +1,4 @@
-//===-- runtime/unit-map.h --------------------------------------*- C++ -*-===//
+//===-- lib/Runtime/unit-map.h ----------------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/unit.cpp b/FortranRuntime/lib/Runtime/unit.cpp
similarity index 99%
rename from flang/runtime/unit.cpp
rename to FortranRuntime/lib/Runtime/unit.cpp
index 4aee8397d477e7..496679ee8ce5f4 100644
--- a/flang/runtime/unit.cpp
+++ b/FortranRuntime/lib/Runtime/unit.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/unit.cpp --------------------------------------------------===//
+//===-- lib/Runtime/unit.cpp ------------------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/unit.h b/FortranRuntime/lib/Runtime/unit.h
similarity index 99%
rename from flang/runtime/unit.h
rename to FortranRuntime/lib/Runtime/unit.h
index a3ea2686816803..608f3a28ef687d 100644
--- a/flang/runtime/unit.h
+++ b/FortranRuntime/lib/Runtime/unit.h
@@ -1,4 +1,4 @@
-//===-- runtime/unit.h ------------------------------------------*- C++ -*-===//
+//===-- lib/Runtime/unit.h --------------------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/utf.cpp b/FortranRuntime/lib/Runtime/utf.cpp
similarity index 98%
rename from flang/runtime/utf.cpp
rename to FortranRuntime/lib/Runtime/utf.cpp
index b09819cb2f736b..635451153d39a6 100644
--- a/flang/runtime/utf.cpp
+++ b/FortranRuntime/lib/Runtime/utf.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/utf.cpp ---------------------------------------------------===//
+//===-- lib/Runtime/utf.cpp -------------------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/utf.h b/FortranRuntime/lib/Runtime/utf.h
similarity index 97%
rename from flang/runtime/utf.h
rename to FortranRuntime/lib/Runtime/utf.h
index 10c2d61484217a..5ba40437ea0c95 100644
--- a/flang/runtime/utf.h
+++ b/FortranRuntime/lib/Runtime/utf.h
@@ -1,4 +1,4 @@
-//===-- runtime/utf.h -----------------------------------------------------===//
+//===-- lib/Runtime/utf.h ---------------------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/FortranRuntime/lib/Testing/CMakeLists.txt b/FortranRuntime/lib/Testing/CMakeLists.txt
new file mode 100644
index 00000000000000..75b38662c2a0fa
--- /dev/null
+++ b/FortranRuntime/lib/Testing/CMakeLists.txt
@@ -0,0 +1,19 @@
+#===-- lib/Testing/CMakeLists.txt ------------------------------------------===#
+#
+# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+# See https://llvm.org/LICENSE.txt for license information.
+# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+#
+#===------------------------------------------------------------------------===#
+
+set(public_headers "")
+file(GLOB_RECURSE public_headers
+  "${FLANGRUNTIME_SOURCE_DIR}/lib/Testing/*.h"
+)
+
+add_fortranruntime_library(NonGTestTesting EXCLUDE_FROM_ALL LINK_TO_LLVM
+  testing.cpp
+  fp-testing.cpp
+ ADDITIONAL_HEADERS
+   ${public_headers}
+)
diff --git a/flang/unittests/Evaluate/fp-testing.cpp b/FortranRuntime/lib/Testing/fp-testing.cpp
similarity index 86%
rename from flang/unittests/Evaluate/fp-testing.cpp
rename to FortranRuntime/lib/Testing/fp-testing.cpp
index 94d8d5086d000b..8541b1406334d3 100644
--- a/flang/unittests/Evaluate/fp-testing.cpp
+++ b/FortranRuntime/lib/Testing/fp-testing.cpp
@@ -1,4 +1,12 @@
-#include "fp-testing.h"
+//===-- lib/Testing/fp-testing.cpp ------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "flang/Testing/fp-testing.h"
 #include "llvm/Support/Errno.h"
 #include <cstdio>
 #include <cstdlib>
@@ -8,7 +16,7 @@
 #endif
 
 using Fortran::common::RoundingMode;
-using Fortran::evaluate::RealFlag;
+using Fortran::common::RealFlag;
 
 ScopedHostFloatingPointEnvironment::ScopedHostFloatingPointEnvironment(
 #if __x86_64__
diff --git a/flang/unittests/Evaluate/testing.cpp b/FortranRuntime/lib/Testing/testing.cpp
similarity index 88%
rename from flang/unittests/Evaluate/testing.cpp
rename to FortranRuntime/lib/Testing/testing.cpp
index b2f73bf1b265a7..37f9d88f4886b4 100644
--- a/flang/unittests/Evaluate/testing.cpp
+++ b/FortranRuntime/lib/Testing/testing.cpp
@@ -1,4 +1,12 @@
-#include "testing.h"
+//===-- lib/Testing/testing.cpp ---------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "flang/Testing/testing.h"
 #include "llvm/Support/raw_ostream.h"
 #include <cstdarg>
 #include <cstdio>
diff --git a/flang/module/.clang-format b/FortranRuntime/module/.clang-format
similarity index 100%
rename from flang/module/.clang-format
rename to FortranRuntime/module/.clang-format
diff --git a/FortranRuntime/module/CMakeLists.txt b/FortranRuntime/module/CMakeLists.txt
new file mode 100644
index 00000000000000..9841cbd586b2df
--- /dev/null
+++ b/FortranRuntime/module/CMakeLists.txt
@@ -0,0 +1,63 @@
+#===-- module/CMakeLists.txt -----------------------------------------------===#
+#
+# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+# See https://llvm.org/LICENSE.txt for license information.
+# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+#
+#===------------------------------------------------------------------------===#
+
+set(module_sources
+  "__cuda_builtins.f90"
+  "__fortran_builtins.f90"
+  "__fortran_ieee_exceptions.f90"
+  "__fortran_type_info.f90"
+  # "cudadevice.f90" # TODO: -fc1 -xcuda
+  "ieee_arithmetic.f90"
+  "ieee_exceptions.f90"
+  "ieee_features.f90"
+  "iso_c_binding.f90"
+  "iso_fortran_env.f90"
+)
+
+set_source_files_properties(
+ "iso_fortran_env.f90"
+ PROPERTIES
+   COMPILE_FLAGS "-mmlir -ignore-module-only-builtins"
+)
+
+set_source_files_properties(
+  "__fortran_builtins.f90"
+   PROPERTIES
+     COMPILE_FLAGS "-mmlir -ignore-missing-type-desc"
+)
+
+# Requires PowerPC vector instructions
+if (LLVM_TARGET_TRIPLE MATCHES "(ppc|powerpc)(32|64)?(le|be)?\-.*")
+  list(APPEND module_sources
+    "__ppc_types.f90"
+    "__ppc_intrinsics.f90"
+    "mma.f90"
+  )
+endif ()
+
+add_fortranruntime_library(module_files OBJECT
+  ${module_sources}
+)
+
+# Usually, CMake will ignore dependencies from Fortran intrinsic modules. Since this is building those intrinsic modules themselves, tell CMake to not prune such dependencies.
+set_target_properties(module_files
+  PROPERTIES
+    Fortran_BUILDING_INSTRINSIC_MODULES ON
+)
+
+# The usual technique to install files in CMake is
+#
+#   install(TARGET <targetname> <artifacttype> ...)
+#
+# However, there is no <artifacttype> for Fortran modules. We have to derive the module file path individually.
+set(module_files "")
+foreach (f90file IN LISTS module_sources)
+   get_filename_component(base "${f90file}" NAME_WE )
+   list(APPEND module_files "${FORTRANRUNTIME_BUILD_INCLUDE_DIR}/flang/${base}.mod")
+endforeach ()
+install(FILES ${module_files} DESTINATION "${FORTRANRUNTIME_INSTALL_INCLUDE_DIR}/flang")
diff --git a/flang/module/__cuda_builtins.f90 b/FortranRuntime/module/__cuda_builtins.f90
similarity index 100%
rename from flang/module/__cuda_builtins.f90
rename to FortranRuntime/module/__cuda_builtins.f90
diff --git a/flang/module/__fortran_builtins.f90 b/FortranRuntime/module/__fortran_builtins.f90
similarity index 100%
rename from flang/module/__fortran_builtins.f90
rename to FortranRuntime/module/__fortran_builtins.f90
diff --git a/flang/module/__fortran_ieee_exceptions.f90 b/FortranRuntime/module/__fortran_ieee_exceptions.f90
similarity index 100%
rename from flang/module/__fortran_ieee_exceptions.f90
rename to FortranRuntime/module/__fortran_ieee_exceptions.f90
diff --git a/flang/module/__fortran_type_info.f90 b/FortranRuntime/module/__fortran_type_info.f90
similarity index 100%
rename from flang/module/__fortran_type_info.f90
rename to FortranRuntime/module/__fortran_type_info.f90
diff --git a/flang/module/__ppc_intrinsics.f90 b/FortranRuntime/module/__ppc_intrinsics.f90
similarity index 100%
rename from flang/module/__ppc_intrinsics.f90
rename to FortranRuntime/module/__ppc_intrinsics.f90
diff --git a/flang/module/__ppc_types.f90 b/FortranRuntime/module/__ppc_types.f90
similarity index 100%
rename from flang/module/__ppc_types.f90
rename to FortranRuntime/module/__ppc_types.f90
diff --git a/flang/module/cudadevice.f90 b/FortranRuntime/module/cudadevice.f90
similarity index 96%
rename from flang/module/cudadevice.f90
rename to FortranRuntime/module/cudadevice.f90
index 0224ecfdde7c60..dd487f6ed1ffee 100644
--- a/flang/module/cudadevice.f90
+++ b/FortranRuntime/module/cudadevice.f90
@@ -1,4 +1,4 @@
-!===-- module/cudedevice.f90 -----------------------------------------------===!
+!===-- module/cudadevice.f90 -----------------------------------------------===!
 !
 ! Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 ! See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/module/ieee_arithmetic.f90 b/FortranRuntime/module/ieee_arithmetic.f90
similarity index 100%
rename from flang/module/ieee_arithmetic.f90
rename to FortranRuntime/module/ieee_arithmetic.f90
diff --git a/flang/module/ieee_exceptions.f90 b/FortranRuntime/module/ieee_exceptions.f90
similarity index 100%
rename from flang/module/ieee_exceptions.f90
rename to FortranRuntime/module/ieee_exceptions.f90
diff --git a/flang/module/ieee_features.f90 b/FortranRuntime/module/ieee_features.f90
similarity index 100%
rename from flang/module/ieee_features.f90
rename to FortranRuntime/module/ieee_features.f90
diff --git a/flang/module/iso_c_binding.f90 b/FortranRuntime/module/iso_c_binding.f90
similarity index 100%
rename from flang/module/iso_c_binding.f90
rename to FortranRuntime/module/iso_c_binding.f90
diff --git a/flang/module/iso_fortran_env.f90 b/FortranRuntime/module/iso_fortran_env.f90
similarity index 100%
rename from flang/module/iso_fortran_env.f90
rename to FortranRuntime/module/iso_fortran_env.f90
diff --git a/flang/module/mma.f90 b/FortranRuntime/module/mma.f90
similarity index 98%
rename from flang/module/mma.f90
rename to FortranRuntime/module/mma.f90
index 4c41822e000a3d..14aab69035a334 100644
--- a/flang/module/mma.f90
+++ b/FortranRuntime/module/mma.f90
@@ -55,9 +55,18 @@ pure __vector_pair function func_vpi0vp(arg1, arg2); \
     !dir$ ignore_tkr(r) arg2; \
   end function;
 
-  FUNC_VPI0VI(1) FUNC_VPI0VI(2) FUNC_VPI0VI(4) FUNC_VPI0VI(8)
-  FUNC_VPI0VU(1) FUNC_VPI0VU(2) FUNC_VPI0VU(4) FUNC_VPI0VU(8)
-  FUNC_VPI0VR(4) FUNC_VPI0VR(8)
+! FIXME: Potential Flang bug: combining multiple of those on a single line breaks after preprocessing as an explicit step as done by CMake
+! Line counting is also wrong
+  FUNC_VPI0VI(1)
+  FUNC_VPI0VI(2)
+  FUNC_VPI0VI(4)
+  FUNC_VPI0VI(8)
+  FUNC_VPI0VU(1)
+  FUNC_VPI0VU(2)
+  FUNC_VPI0VU(4)
+  FUNC_VPI0VU(8)
+  FUNC_VPI0VR(4)
+  FUNC_VPI0VR(8)
   FUNC_VPI0VP
 
 #undef FUNC_VPI0VP
@@ -144,14 +153,26 @@ elemental subroutine sub_vpvr##VKIND##vr##VKIND(pair, arg1, arg2); \
     vector(real(VKIND)), intent(in) :: arg1, arg2; \
   end subroutine ;
 
-  ELEM_SUB_VPVIVI(1) ELEM_SUB_VPVIVI(2)
-  ELEM_SUB_VPVIVI(4) ELEM_SUB_VPVIVI(8)
-  ELEM_SUB_VPVUVU(1) ELEM_SUB_VPVUVU(2)
-  ELEM_SUB_VPVUVU(4) ELEM_SUB_VPVUVU(8)
-  ELEM_SUB_VPVRVR(4) ELEM_SUB_VPVRVR(8)
-  SUB_VPI0VI(1) SUB_VPI0VI(2) SUB_VPI0VI(4) SUB_VPI0VI(8)
-  SUB_VPI0VU(1) SUB_VPI0VU(2) SUB_VPI0VU(4) SUB_VPI0VU(8)
-  SUB_VPI0VR(4) SUB_VPI0VR(8)
+  ELEM_SUB_VPVIVI(1)
+  ELEM_SUB_VPVIVI(2)
+  ELEM_SUB_VPVIVI(4)
+  ELEM_SUB_VPVIVI(8)
+  ELEM_SUB_VPVUVU(1)
+  ELEM_SUB_VPVUVU(2)
+  ELEM_SUB_VPVUVU(4)
+  ELEM_SUB_VPVUVU(8)
+  ELEM_SUB_VPVRVR(4)
+  ELEM_SUB_VPVRVR(8)
+  SUB_VPI0VI(1)
+  SUB_VPI0VI(2)
+  SUB_VPI0VI(4)
+  SUB_VPI0VI(8)
+  SUB_VPI0VU(1)
+  SUB_VPI0VU(2)
+  SUB_VPI0VU(4)
+  SUB_VPI0VU(8)
+  SUB_VPI0VR(4)
+  SUB_VPI0VR(8)
 
 #undef ELEM_SUB_VPVIVI
 #undef ELEM_SUB_VPVUVU
diff --git a/FortranRuntime/test/CMakeLists.txt b/FortranRuntime/test/CMakeLists.txt
new file mode 100644
index 00000000000000..1f822859089f3d
--- /dev/null
+++ b/FortranRuntime/test/CMakeLists.txt
@@ -0,0 +1,70 @@
+#===-- test/CMakeLists.txt -------------------------------------------------===#
+#
+# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+# See https://llvm.org/LICENSE.txt for license information.
+# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+#
+#===------------------------------------------------------------------------===#
+
+# Test runner infrastructure for Flang. This configures the Flang test trees
+# for use by Lit, and delegates to LLVM's lit test handlers.
+
+llvm_canonicalize_cmake_booleans(
+  FLANG_STANDALONE_BUILD
+  LLVM_BUILD_EXAMPLES
+  LLVM_BYE_LINK_INTO_TOOLS
+  LLVM_ENABLE_PLUGINS
+)
+
+set(FLANG_TOOLS_DIR ${FLANG_BINARY_DIR}/bin)
+
+configure_lit_site_cfg(
+  ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in
+  ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg.py
+  MAIN_CONFIG
+  ${CMAKE_CURRENT_SOURCE_DIR}/lit.cfg.py
+)
+
+if (TARGET FortranRuntimeUnitTests)
+  configure_lit_site_cfg(
+    ${CMAKE_CURRENT_SOURCE_DIR}/Unit/lit.site.cfg.py.in
+    ${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg.py
+    MAIN_CONFIG
+    ${CMAKE_CURRENT_SOURCE_DIR}/Unit/lit.cfg.py
+  )
+
+  configure_lit_site_cfg(
+    ${CMAKE_CURRENT_SOURCE_DIR}/NonGtestUnit/lit.site.cfg.py.in
+    ${CMAKE_CURRENT_BINARY_DIR}/NonGtestUnit/lit.site.cfg.py
+    MAIN_CONFIG
+    ${CMAKE_CURRENT_SOURCE_DIR}/NonGtestUnit/lit.cfg.py
+  )
+endif ()
+
+set(FORTRANRUNTIME_TEST_DEPENDS "")
+if (FORTRANRUNTIME_INCLUDE_TESTS)
+  if (TARGET FortranRuntimeUnitTests)
+    list(APPEND FORTRANRUNTIME_TEST_DEPENDS FortranRuntimeUnitTests)
+  endif()
+endif()
+
+add_custom_target(FortranRuntime-test-depends)
+set_target_properties(FortranRuntime-test-depends PROPERTIES FOLDER "Fortran Runtime/Meta")
+
+add_lit_testsuite(check-FortranRuntime "Running the Flang regression tests"
+  ${CMAKE_CURRENT_BINARY_DIR}
+  DEPENDS ${FORTRANRUNTIME_TEST_DEPENDS}
+)
+set_target_properties(check-FortranRuntime PROPERTIES FOLDER "Fortran Runtime/Meta")
+
+
+add_lit_testsuites(FORTRANRUNTIME ${CMAKE_CURRENT_SOURCE_DIR}
+  DEPENDS ${FORTRANRUNTIME_TEST_DEPENDS})
+
+# To modify the default target triple for flang tests.
+if (DEFINED FLANG_TEST_TARGET_TRIPLE)
+  if (NOT DEFINED LLVM_TARGET_TRIPLE_ENV OR LLVM_TARGET_TRIPLE_ENV STREQUAL "")
+    message(FATAL_ERROR "LLVM_TARGET_TRIPLE_ENV must also be defined in order "
+                        "to use FLANG_TEST_TARGET_TRIPLE.")
+  endif()
+endif()
diff --git a/FortranRuntime/test/NonGtestUnit/lit.cfg.py b/FortranRuntime/test/NonGtestUnit/lit.cfg.py
new file mode 100644
index 00000000000000..cd78ca76de503f
--- /dev/null
+++ b/FortranRuntime/test/NonGtestUnit/lit.cfg.py
@@ -0,0 +1,21 @@
+# -*- Python -*-
+
+import os
+
+import lit.formats
+
+# name: The name of this test suite.
+config.name = "FortranRuntime-OldUnit"
+
+# suffixes: A list of file extensions to treat as test files.
+config.suffixes = [".test"]
+
+# test_source_root: The root path where unit test binaries are located.
+config.test_source_root = os.path.join(config.fortranruntime_binary_dir, "unittests")
+
+# test_exec_root: The root path where tests should be run.
+# lit writes a '.lit_test_times.txt' file into this directory.
+config.test_exec_root = config.fortranruntime_binary_test_dir
+
+# testFormat: The test format to use to interpret tests.
+config.test_format = lit.formats.ExecutableTest()
diff --git a/FortranRuntime/test/NonGtestUnit/lit.site.cfg.py.in b/FortranRuntime/test/NonGtestUnit/lit.site.cfg.py.in
new file mode 100644
index 00000000000000..3d1780a5d600a9
--- /dev/null
+++ b/FortranRuntime/test/NonGtestUnit/lit.site.cfg.py.in
@@ -0,0 +1,13 @@
+ at LIT_SITE_CFG_IN_HEADER@
+
+import os
+
+config.llvm_tools_dir = "@LLVM_TOOLS_DIR@"
+config.fortranruntime_binary_dir = "@FORTRANRUNTIME_BINARY_DIR@"
+config.fortranruntime_binary_test_dir = os.path.dirname(__file__)
+
+import lit.llvm
+lit.llvm.initialize(lit_config, config)
+
+# Let the main config do the real work.
+lit_config.load_config(config, "@FORTRANRUNTIME_SOURCE_DIR@/test/NonGtestUnit/lit.cfg.py")
diff --git a/flang/test/Runtime/no-cpp-dep.c b/FortranRuntime/test/Runtime/no-cpp-dep.c
similarity index 75%
rename from flang/test/Runtime/no-cpp-dep.c
rename to FortranRuntime/test/Runtime/no-cpp-dep.c
index 606a5d189f7199..f6760b75a148ff 100644
--- a/flang/test/Runtime/no-cpp-dep.c
+++ b/FortranRuntime/test/Runtime/no-cpp-dep.c
@@ -3,16 +3,18 @@ This test makes sure that flang's runtime does not depend on the C++ runtime
 library. It tries to link this simple file against libFortranRuntime.a with
 a C compiler.
 
-REQUIRES: c-compiler
+UNSUPPORTED: system-windows
 
 RUN: %if system-aix %{ export OBJECT_MODE=64 %}
-RUN: %cc -std=c99 %s -I%include %libruntime %libdecimal -lm  \
+RUN: %cc -std=c99 %s -I%include %libruntime -lm \
 RUN: %if system-aix %{-lpthread %}
 RUN: rm a.out
 */
 
 #include "flang/Runtime/entry-names.h"
 #include <stdint.h>
+#include <stdbool.h>
+#include <stddef.h>
 
 /*
 Manually add declarations for the runtime functions that we want to make sure
@@ -29,7 +31,9 @@ void RTNAME(ProgramStart)(
 int32_t RTNAME(ArgumentCount)();
 int32_t RTNAME(GetCommandArgument)(int32_t, const struct Descriptor *,
     const struct Descriptor *, const struct Descriptor *);
-int32_t RTNAME(GetEnvVariable)();
+int32_t RTNAME(GetEnvVariable)(const struct Descriptor *,
+    const struct Descriptor *, const struct Descriptor *, bool ,
+    const struct Descriptor *, const char *, int );
 int64_t RTNAME(SystemClockCount)(int kind);
 
 int main() {
@@ -37,7 +41,7 @@ int main() {
   RTNAME(ProgramStart)(0, 0, 0, 0);
   int32_t c = RTNAME(ArgumentCount)();
   int32_t v = RTNAME(GetCommandArgument)(0, 0, 0, 0);
-  int32_t e = RTNAME(GetEnvVariable)("FOO", 0, 0);
+  int32_t e = RTNAME(GetEnvVariable)(NULL, NULL, NULL, false, NULL, "FOO", 0);
   int64_t t = RTNAME(SystemClockCount)(8);
   return x + c + v + e;
 }
diff --git a/FortranRuntime/test/Unit/lit.cfg.py b/FortranRuntime/test/Unit/lit.cfg.py
new file mode 100644
index 00000000000000..888fb3981916c8
--- /dev/null
+++ b/FortranRuntime/test/Unit/lit.cfg.py
@@ -0,0 +1,21 @@
+# -*- Python -*-
+
+import os
+
+import lit.formats
+
+# name: The name of this test suite.
+config.name = "FortranRuntime-Unit"
+
+# suffixes: A list of file extensions to treat as test files.
+config.suffixes = []
+
+# test_source_root: The root path where unit test binaries are located.
+config.test_source_root = os.path.join(config.fortranruntime_binary_dir, "unittests")
+
+# test_exec_root: The root path where tests should be run.
+# lit writes a '.lit_test_times.txt' file into this directory.
+config.test_exec_root = config.fortranruntime_binary_test_dir
+
+# testFormat: The test format to use to interpret tests.
+config.test_format = lit.formats.GoogleTest(config.llvm_build_mode, "Tests")
diff --git a/FortranRuntime/test/Unit/lit.site.cfg.py.in b/FortranRuntime/test/Unit/lit.site.cfg.py.in
new file mode 100644
index 00000000000000..fa993aa897faca
--- /dev/null
+++ b/FortranRuntime/test/Unit/lit.site.cfg.py.in
@@ -0,0 +1,14 @@
+ at LIT_SITE_CFG_IN_HEADER@
+
+import os
+
+config.llvm_tools_dir = "@LLVM_TOOLS_DIR@"
+config.llvm_build_mode = "@LLVM_BUILD_MODE@"
+config.fortranruntime_binary_dir = "@FORTRANRUNTIME_BINARY_DIR@"
+config.fortranruntime_binary_test_dir = os.path.dirname(__file__)
+
+import lit.llvm
+lit.llvm.initialize(lit_config, config)
+
+# Let the main config do the real work.
+lit_config.load_config(config, "@FORTRANRUNTIME_SOURCE_DIR@/test/Unit/lit.cfg.py")
diff --git a/FortranRuntime/test/lit.cfg.py b/FortranRuntime/test/lit.cfg.py
new file mode 100644
index 00000000000000..dd5124b8de4095
--- /dev/null
+++ b/FortranRuntime/test/lit.cfg.py
@@ -0,0 +1,78 @@
+# -*- Python -*-
+
+import lit.util
+
+from lit.llvm import llvm_config
+from lit.llvm.subst import ToolSubst
+
+# Configuration file for the 'lit' test runner.
+
+# name: The name of this test suite.
+config.name = "FortranRuntime"
+
+# testFormat: The test format to use to interpret tests.
+#
+# For now we require '&&' between commands, until they get globally killed and
+# the test runner updated.
+config.test_format = lit.formats.ShTest(not llvm_config.use_lit_shell)
+
+# suffixes: A list of file extensions to treat as test files.
+config.suffixes = [
+    ".c",
+    ".cpp",
+    ".f",
+    ".F",
+    ".ff",
+    ".FOR",
+    ".for",
+    ".f77",
+    ".f90",
+    ".F90",
+    ".ff90",
+    ".f95",
+    ".F95",
+    ".ff95",
+    ".fpp",
+    ".FPP",
+    ".cuf",
+    ".CUF",
+    ".f18",
+    ".F18",
+    ".f03",
+    ".F03",
+    ".f08",
+    ".F08",
+    ".ll",
+    ".fir",
+    ".mlir",
+]
+
+llvm_config.use_default_substitutions()
+
+# test_source_root: The root path where tests are located.
+config.test_source_root = os.path.dirname(__file__)
+
+# test_exec_root: The root path where tests should be run. 
+# lit writes a '.lit_test_times.txt' file into this directory.
+config.test_exec_root = config.fortranruntime_binary_test_dir
+
+# On MacOS, -isysroot is needed to build binaries.
+isysroot_flag = []
+if config.osx_sysroot:
+    isysroot_flag = ["-isysroot", config.osx_sysroot]
+
+# Define some variables to help us test that the flang runtime doesn't depend on
+# the C++ runtime libraries. For this we need a C compiler.
+libruntime = os.path.join(config.fortranruntime_build_lib_dir, "libFortranRuntime.a")
+include = os.path.join(config.fortranruntime_source_dir, "include")
+tools = []
+tools.append(
+            ToolSubst(
+                "%cc", command=config.cc, extra_args=isysroot_flag, unresolved="fatal"
+            )
+        )
+tools.append(ToolSubst("%libruntime", command=libruntime, unresolved="fatal"))
+tools.append(ToolSubst("%include", command=include, unresolved="fatal"))
+
+llvm_config.add_tool_substitutions(tools)
+
diff --git a/FortranRuntime/test/lit.site.cfg.py.in b/FortranRuntime/test/lit.site.cfg.py.in
new file mode 100644
index 00000000000000..d860d297ebd7c3
--- /dev/null
+++ b/FortranRuntime/test/lit.site.cfg.py.in
@@ -0,0 +1,17 @@
+ at LIT_SITE_CFG_IN_HEADER@
+
+import sys
+
+config.llvm_tools_dir = "@LLVM_TOOLS_DIR@"
+config.build_lib_dir = "@FORTRANRUNTIME_BUILD_LIB_DIR@"
+config.fortranruntime_source_dir = "@FORTRANRUNTIME_SOURCE_DIR@"
+config.fortranruntime_binary_test_dir = os.path.dirname(__file__)
+config.fortranruntime_build_lib_dir = "@FORTRANRUNTIME_BUILD_LIB_DIR@"
+config.cc = "@CMAKE_C_COMPILER@"
+config.osx_sysroot = path(r"@CMAKE_OSX_SYSROOT@")
+
+import lit.llvm
+lit.llvm.initialize(lit_config, config)
+
+# Let the main config do the real work.
+lit_config.load_config(config, "@FORTRANRUNTIME_SOURCE_DIR@/test/lit.cfg.py")
diff --git a/FortranRuntime/unittests/CMakeLists.txt b/FortranRuntime/unittests/CMakeLists.txt
new file mode 100644
index 00000000000000..d1aed058aad142
--- /dev/null
+++ b/FortranRuntime/unittests/CMakeLists.txt
@@ -0,0 +1,62 @@
+#===-- unittests/CMakeLists.txt --------------------------------------------===#
+#
+# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+# See https://llvm.org/LICENSE.txt for license information.
+# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+#
+#===------------------------------------------------------------------------===#
+
+function (build_gtest)
+  include_directories("${LLVM_INCLUDE_DIR}" "${LLVM_MAIN_INCLUDE_DIR}")
+  set(LLVM_SUBPROJECT_TITLE "Third-Party/Google Test")
+  add_subdirectory(${LLVM_THIRD_PARTY_DIR}/unittest ${CMAKE_CURRENT_BINARY_DIR}/third-party/unittest)
+endfunction ()
+
+# Add GTest if not already present
+if (NOT TARGET llvm_gtest)
+  build_gtest()
+endif ()
+
+# Target that depends on all unittests
+add_custom_target(FortranRuntimeUnitTests)
+set_target_properties(FortranRuntimeUnitTests PROPERTIES FOLDER "Fortran Runtime/Tests")
+
+function(add_fortranruntime_unittest test_dirname)
+  cmake_parse_arguments(ARG
+    ""
+    ""
+    "LINK_LIBS"
+    ${ARGN})
+
+  add_unittest(FortranRuntimeUnitTests ${test_dirname} ${ARG_UNPARSED_ARGUMENTS})
+  target_include_directories(${test_dirname} PRIVATE "${FORTRANRUNTIME_SOURCE_DIR}/include")
+  target_link_libraries(${test_dirname} PRIVATE ${ARG_LINK_LIBS})
+endfunction()
+
+function(add_fortranruntime_nongtest_unittest test_name)
+  cmake_parse_arguments(ARG
+    "SLOW_TEST"
+    ""
+    "LINK_LIBS"
+    ${ARGN})
+
+  if(ARG_SLOW_TEST)
+      set(suffix .slow)
+  else()
+      set(suffix .test)
+  endif()
+
+  add_executable(${test_name}${suffix} ${ARG_UNPARSED_ARGUMENTS})
+  target_link_libraries(${test_name}${suffix} PRIVATE NonGTestTesting ${ARG_LINK_LIBS})
+  target_include_directories(${test_name}${suffix} PRIVATE "${FORTRANRUNTIME_SOURCE_DIR}/include")
+  set_target_properties(${test_name}${suffix} PROPERTIES FOLDER "Fortran Runtime/Tests/Unit")
+
+  if(NOT ARG_SLOW_TEST)
+    add_dependencies(FortranRuntimeUnitTests ${test_name}${suffix})
+  endif()
+endfunction()
+
+add_subdirectory(Common)
+add_subdirectory(Decimal)
+add_subdirectory(Evaluate)
+add_subdirectory(Runtime)
diff --git a/FortranRuntime/unittests/Common/CMakeLists.txt b/FortranRuntime/unittests/Common/CMakeLists.txt
new file mode 100644
index 00000000000000..f107036f19ed8d
--- /dev/null
+++ b/FortranRuntime/unittests/Common/CMakeLists.txt
@@ -0,0 +1,13 @@
+#===-- unittests/Common/CMakeLists.txt -------------------------------------===#
+#
+# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+# See https://llvm.org/LICENSE.txt for license information.
+# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+#
+#===------------------------------------------------------------------------===#
+
+add_fortranruntime_unittest(FlangCommonTests
+  FastIntSetTest.cpp
+  LINK_LIBS
+    FortranRuntime.static
+)
diff --git a/flang/unittests/Common/FastIntSetTest.cpp b/FortranRuntime/unittests/Common/FastIntSetTest.cpp
similarity index 97%
rename from flang/unittests/Common/FastIntSetTest.cpp
rename to FortranRuntime/unittests/Common/FastIntSetTest.cpp
index bd1b953fa16631..f19359f4097ab8 100644
--- a/flang/unittests/Common/FastIntSetTest.cpp
+++ b/FortranRuntime/unittests/Common/FastIntSetTest.cpp
@@ -1,4 +1,4 @@
-//===-- flang/unittests/Common/FastIntSetTest.cpp ---------------*- C++ -*-===//
+//===-- unittests/Common/FastIntSetTest.cpp ---------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/FortranRuntime/unittests/Decimal/CMakeLists.txt b/FortranRuntime/unittests/Decimal/CMakeLists.txt
new file mode 100644
index 00000000000000..3d96da45c94148
--- /dev/null
+++ b/FortranRuntime/unittests/Decimal/CMakeLists.txt
@@ -0,0 +1,20 @@
+#===-- unittests/Decimal/CMakeLists.txt ------------------------------------===#
+#
+# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+# See https://llvm.org/LICENSE.txt for license information.
+# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+#
+#===------------------------------------------------------------------------===#
+
+add_fortranruntime_nongtest_unittest(quick-sanity-test
+quick-sanity-test.cpp
+LINK_LIBS
+  FortranRuntime.static
+)
+
+# This test is not run by default as it takes a long time to execute.
+add_fortranruntime_nongtest_unittest(thorough-test SLOW_TEST
+thorough-test.cpp
+LINK_LIBS
+  FortranRuntime.static
+)
diff --git a/flang/unittests/Decimal/quick-sanity-test.cpp b/FortranRuntime/unittests/Decimal/quick-sanity-test.cpp
similarity index 91%
rename from flang/unittests/Decimal/quick-sanity-test.cpp
rename to FortranRuntime/unittests/Decimal/quick-sanity-test.cpp
index dafb075307ab6a..0e8ff0ce48b3c6 100644
--- a/flang/unittests/Decimal/quick-sanity-test.cpp
+++ b/FortranRuntime/unittests/Decimal/quick-sanity-test.cpp
@@ -1,4 +1,12 @@
-#include "flang/Decimal/decimal.h"
+//===-- unittests/Decimal/quick-sanity-test.cpp -----------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "flang/Common/decimal.h"
 #include "llvm/Support/raw_ostream.h"
 #include <cinttypes>
 #include <cstdio>
diff --git a/flang/unittests/Decimal/thorough-test.cpp b/FortranRuntime/unittests/Decimal/thorough-test.cpp
similarity index 85%
rename from flang/unittests/Decimal/thorough-test.cpp
rename to FortranRuntime/unittests/Decimal/thorough-test.cpp
index 46951f33eb8fee..0648b61d7c1cda 100644
--- a/flang/unittests/Decimal/thorough-test.cpp
+++ b/FortranRuntime/unittests/Decimal/thorough-test.cpp
@@ -1,4 +1,12 @@
-#include "flang/Decimal/decimal.h"
+//===-- unittests/Decimal/thorough-test.cpp ---------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "flang/Common/decimal.h"
 #include "llvm/Support/raw_ostream.h"
 #include <cinttypes>
 #include <cstdio>
diff --git a/FortranRuntime/unittests/Evaluate/CMakeLists.txt b/FortranRuntime/unittests/Evaluate/CMakeLists.txt
new file mode 100644
index 00000000000000..e6501f13a74e6b
--- /dev/null
+++ b/FortranRuntime/unittests/Evaluate/CMakeLists.txt
@@ -0,0 +1,19 @@
+#===-- unittests/Evaluate/CMakeLists.txt -----------------------------------===#
+#
+# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+# See https://llvm.org/LICENSE.txt for license information.
+# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+#
+#===------------------------------------------------------------------------===#
+
+add_fortranruntime_nongtest_unittest(reshape
+reshape.cpp
+LINK_LIBS
+  FortranRuntime.static
+)
+
+add_fortranruntime_nongtest_unittest(ISO-Fortran-binding
+ISO-Fortran-binding.cpp
+LINK_LIBS
+  FortranRuntime.static
+)
diff --git a/flang/unittests/Evaluate/ISO-Fortran-binding.cpp b/FortranRuntime/unittests/Evaluate/ISO-Fortran-binding.cpp
similarity index 98%
rename from flang/unittests/Evaluate/ISO-Fortran-binding.cpp
rename to FortranRuntime/unittests/Evaluate/ISO-Fortran-binding.cpp
index 3c98363f900466..97d23ca90e5022 100644
--- a/flang/unittests/Evaluate/ISO-Fortran-binding.cpp
+++ b/FortranRuntime/unittests/Evaluate/ISO-Fortran-binding.cpp
@@ -1,5 +1,13 @@
-#include "testing.h"
-#include "flang/ISO_Fortran_binding_wrapper.h"
+//===-- unittests/Evaluate/ISO-Fortran-binding.cpp --------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "flang/Testing/testing.h"
+#include "flang/Common/ISO_Fortran_binding_wrapper.h"
 #include "flang/Runtime/descriptor.h"
 #include "llvm/Support/raw_ostream.h"
 #include <type_traits>
diff --git a/flang/unittests/Evaluate/reshape.cpp b/FortranRuntime/unittests/Evaluate/reshape.cpp
similarity index 88%
rename from flang/unittests/Evaluate/reshape.cpp
rename to FortranRuntime/unittests/Evaluate/reshape.cpp
index 5d138cd3d88d98..82caebe081fcd2 100644
--- a/flang/unittests/Evaluate/reshape.cpp
+++ b/FortranRuntime/unittests/Evaluate/reshape.cpp
@@ -1,4 +1,12 @@
-#include "testing.h"
+//===-- unittests/Evaluate/reshape.cpp --------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "flang/Testing/testing.h"
 #include "flang/Runtime/descriptor.h"
 #include "flang/Runtime/transformational.h"
 #include <cinttypes>
diff --git a/flang/unittests/Runtime/AccessTest.cpp b/FortranRuntime/unittests/Runtime/AccessTest.cpp
similarity index 99%
rename from flang/unittests/Runtime/AccessTest.cpp
rename to FortranRuntime/unittests/Runtime/AccessTest.cpp
index 66f19f78c7cfb6..e72386cc9ac247 100644
--- a/flang/unittests/Runtime/AccessTest.cpp
+++ b/FortranRuntime/unittests/Runtime/AccessTest.cpp
@@ -1,4 +1,4 @@
-//===-- flang/unittests/Runtime/AccessTest.cpp ----------------------------===//
+//===-- unittests/Runtime/AccessTest.cpp ------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/unittests/Runtime/Allocatable.cpp b/FortranRuntime/unittests/Runtime/Allocatable.cpp
similarity index 98%
rename from flang/unittests/Runtime/Allocatable.cpp
rename to FortranRuntime/unittests/Runtime/Allocatable.cpp
index f15f26bfd9c575..8e10dc408ceae8 100644
--- a/flang/unittests/Runtime/Allocatable.cpp
+++ b/FortranRuntime/unittests/Runtime/Allocatable.cpp
@@ -1,4 +1,4 @@
-//===-- flang/unittests/Runtime/Allocatable.cpp--------- ---------*- C++-*-===//
+//===-- unittests/Runtime/Allocatable.cpp -----------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/unittests/Runtime/ArrayConstructor.cpp b/FortranRuntime/unittests/Runtime/ArrayConstructor.cpp
similarity index 99%
rename from flang/unittests/Runtime/ArrayConstructor.cpp
rename to FortranRuntime/unittests/Runtime/ArrayConstructor.cpp
index 9d78da79623613..8c7fce3e4fb5f7 100644
--- a/flang/unittests/Runtime/ArrayConstructor.cpp
+++ b/FortranRuntime/unittests/Runtime/ArrayConstructor.cpp
@@ -1,4 +1,4 @@
-//===-- flang/unittests/Runtime/ArrayConstructor.cpp-------------*- C++ -*-===//
+//===-- unittests/Runtime/ArrayConstructor.cpp ------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/unittests/Runtime/BufferTest.cpp b/FortranRuntime/unittests/Runtime/BufferTest.cpp
similarity index 97%
rename from flang/unittests/Runtime/BufferTest.cpp
rename to FortranRuntime/unittests/Runtime/BufferTest.cpp
index 0632324b25d22e..9a7dd86d0c1dc6 100644
--- a/flang/unittests/Runtime/BufferTest.cpp
+++ b/FortranRuntime/unittests/Runtime/BufferTest.cpp
@@ -1,4 +1,4 @@
-//===-- flang/unittests/Runtime/BufferTest.cpp ------------------*- C++ -*-===//
+//===-- unittests/Runtime/BufferTest.cpp ------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -6,7 +6,7 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "../../runtime/buffer.h"
+#include "../../lib/Runtime/buffer.h"
 #include "CrashHandlerFixture.h"
 #include "gtest/gtest.h"
 #include <algorithm>
diff --git a/flang/unittests/Runtime/CMakeLists.txt b/FortranRuntime/unittests/Runtime/CMakeLists.txt
similarity index 54%
rename from flang/unittests/Runtime/CMakeLists.txt
rename to FortranRuntime/unittests/Runtime/CMakeLists.txt
index 2c3f8c1a9e9ac8..1e966987c272a0 100644
--- a/flang/unittests/Runtime/CMakeLists.txt
+++ b/FortranRuntime/unittests/Runtime/CMakeLists.txt
@@ -1,4 +1,12 @@
-add_flang_unittest(FlangRuntimeTests
+#===-- unittests/Runtime/CMakeLists.txt ------------------------------------===#
+#
+# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+# See https://llvm.org/LICENSE.txt for license information.
+# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+#
+#===------------------------------------------------------------------------===#
+
+add_fortranruntime_unittest(FlangRuntimeTests
   AccessTest.cpp
   Allocatable.cpp
   ArrayConstructor.cpp
@@ -29,11 +37,6 @@ add_flang_unittest(FlangRuntimeTests
   Time.cpp
   TemporaryStack.cpp
   Transformational.cpp
+LINK_LIBS
+  FortranRuntime.static
 )
-
-target_link_libraries(FlangRuntimeTests
-  PRIVATE
-  FortranRuntime
-)
-
-add_subdirectory(CUDA)
diff --git a/flang/unittests/Runtime/CUDA/AllocatorCUF.cpp b/FortranRuntime/unittests/Runtime/CUDA/AllocatorCUF.cpp
similarity index 95%
rename from flang/unittests/Runtime/CUDA/AllocatorCUF.cpp
rename to FortranRuntime/unittests/Runtime/CUDA/AllocatorCUF.cpp
index b51ff0ac006cc6..5bafb484236340 100644
--- a/flang/unittests/Runtime/CUDA/AllocatorCUF.cpp
+++ b/FortranRuntime/unittests/Runtime/CUDA/AllocatorCUF.cpp
@@ -1,4 +1,4 @@
-//===-- flang/unittests/Runtime/AllocatableCUF.cpp ---------------*- C++-*-===//
+//===-- unittests/Runtime/CUDA/AllocatorCUF.cpp -----------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -8,7 +8,7 @@
 
 #include "gtest/gtest.h"
 #include "../../../runtime/terminator.h"
-#include "flang/Common/Fortran.h"
+#include "flang/Support/Fortran.h"
 #include "flang/Runtime/CUDA/allocator.h"
 #include "flang/Runtime/CUDA/descriptor.h"
 #include "flang/Runtime/allocatable.h"
diff --git a/flang/unittests/Runtime/CharacterTest.cpp b/FortranRuntime/unittests/Runtime/CharacterTest.cpp
similarity index 99%
rename from flang/unittests/Runtime/CharacterTest.cpp
rename to FortranRuntime/unittests/Runtime/CharacterTest.cpp
index e54fd8a5075f64..710c1ca0eee817 100644
--- a/flang/unittests/Runtime/CharacterTest.cpp
+++ b/FortranRuntime/unittests/Runtime/CharacterTest.cpp
@@ -1,4 +1,4 @@
-//===-- flang/unittests/Runtime/CharacterTest.cpp ---------------*- C++ -*-===//
+//===-- unittests/Runtime/CharacterTest.cpp ---------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/unittests/Runtime/CommandTest.cpp b/FortranRuntime/unittests/Runtime/CommandTest.cpp
similarity index 99%
rename from flang/unittests/Runtime/CommandTest.cpp
rename to FortranRuntime/unittests/Runtime/CommandTest.cpp
index b0c43ba01d8f33..03a31ceab8030b 100644
--- a/flang/unittests/Runtime/CommandTest.cpp
+++ b/FortranRuntime/unittests/Runtime/CommandTest.cpp
@@ -1,4 +1,4 @@
-//===-- flang/unittests/Runtime/CommandTest.cpp ---------------------------===//
+//===-- unittests/Runtime/CommandTest.cpp -----------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/unittests/Runtime/Complex.cpp b/FortranRuntime/unittests/Runtime/Complex.cpp
similarity index 98%
rename from flang/unittests/Runtime/Complex.cpp
rename to FortranRuntime/unittests/Runtime/Complex.cpp
index 46f3ad2f2712b2..daa4b5c7960842 100644
--- a/flang/unittests/Runtime/Complex.cpp
+++ b/FortranRuntime/unittests/Runtime/Complex.cpp
@@ -1,4 +1,4 @@
-//===-- flang/unittests/Runtime/Complex.cpp ---------------------*- C++ -*-===//
+//===-- unittests/Runtime/Complex.cpp ---------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -13,7 +13,7 @@
 #pragma clang diagnostic ignored "-Wc99-extensions"
 #endif
 
-#include "flang/Common/Fortran.h"
+#include "flang/Common/Fortran-consts.h"
 #include "flang/Runtime/cpp-type.h"
 #include "flang/Runtime/entry-names.h"
 
diff --git a/flang/unittests/Runtime/CrashHandlerFixture.cpp b/FortranRuntime/unittests/Runtime/CrashHandlerFixture.cpp
similarity index 92%
rename from flang/unittests/Runtime/CrashHandlerFixture.cpp
rename to FortranRuntime/unittests/Runtime/CrashHandlerFixture.cpp
index 811603337e6608..5e0b746c7e974a 100644
--- a/flang/unittests/Runtime/CrashHandlerFixture.cpp
+++ b/FortranRuntime/unittests/Runtime/CrashHandlerFixture.cpp
@@ -1,4 +1,4 @@
-//===-- flang/unittests/Runtime/CrashHandlerFixture.cpp ---------*- C++ -*-===//
+//===-- unittests/Runtime/CrashHandlerFixture.cpp ---------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -6,7 +6,7 @@
 //
 //===----------------------------------------------------------------------===//
 #include "CrashHandlerFixture.h"
-#include "../../runtime/terminator.h"
+#include "../../lib/Runtime/terminator.h"
 #include <cstdarg>
 #include <cstdlib>
 
diff --git a/flang/unittests/Runtime/CrashHandlerFixture.h b/FortranRuntime/unittests/Runtime/CrashHandlerFixture.h
similarity index 91%
rename from flang/unittests/Runtime/CrashHandlerFixture.h
rename to FortranRuntime/unittests/Runtime/CrashHandlerFixture.h
index fe0ee0da5204e4..af6d8e4cc7d525 100644
--- a/flang/unittests/Runtime/CrashHandlerFixture.h
+++ b/FortranRuntime/unittests/Runtime/CrashHandlerFixture.h
@@ -1,4 +1,4 @@
-//===-- flang/unittests/Runtime/CrashHandlerFixture.h -----------*- C++ -*-===//
+//===-- unittests/Runtime/CrashHandlerFixture.h -----------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/unittests/Runtime/Derived.cpp b/FortranRuntime/unittests/Runtime/Derived.cpp
similarity index 96%
rename from flang/unittests/Runtime/Derived.cpp
rename to FortranRuntime/unittests/Runtime/Derived.cpp
index 019d5e8309e4a0..8d5471e3e0bcf3 100644
--- a/flang/unittests/Runtime/Derived.cpp
+++ b/FortranRuntime/unittests/Runtime/Derived.cpp
@@ -1,4 +1,4 @@
-//===-- flang/unittests/Runtime/Pointer.cpp--------- -------------*- C++-*-===//
+//===-- unittests/Runtime/Derived.cpp ---------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/unittests/Runtime/ExternalIOTest.cpp b/FortranRuntime/unittests/Runtime/ExternalIOTest.cpp
similarity index 99%
rename from flang/unittests/Runtime/ExternalIOTest.cpp
rename to FortranRuntime/unittests/Runtime/ExternalIOTest.cpp
index 13327964e12a48..23c1e9992c101e 100644
--- a/flang/unittests/Runtime/ExternalIOTest.cpp
+++ b/FortranRuntime/unittests/Runtime/ExternalIOTest.cpp
@@ -1,4 +1,4 @@
-//===-- flang/unittests/RuntimeGTest/ExternalIOTest.cpp ---------*- C++ -*-===//
+//===-- unittests/Runtime/ExternalIOTest.cpp --------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/unittests/Runtime/Format.cpp b/FortranRuntime/unittests/Runtime/Format.cpp
similarity index 96%
rename from flang/unittests/Runtime/Format.cpp
rename to FortranRuntime/unittests/Runtime/Format.cpp
index 01803c628de26a..f1447608917f2d 100644
--- a/flang/unittests/Runtime/Format.cpp
+++ b/FortranRuntime/unittests/Runtime/Format.cpp
@@ -1,4 +1,4 @@
-//===-- flang/unittests/Runtime/Format.cpp ----------------------*- C++ -*-===//
+//===-- unittests/Runtime/Format.cpp ----------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -7,9 +7,9 @@
 //===----------------------------------------------------------------------===//
 
 #include "CrashHandlerFixture.h"
-#include "../runtime/connection.h"
-#include "../runtime/format-implementation.h"
-#include "../runtime/io-error.h"
+#include "../../lib/Runtime/connection.h"
+#include "../../lib/Runtime/format-implementation.h"
+#include "../../lib/Runtime/io-error.h"
 #include <optional>
 #include <string>
 #include <tuple>
diff --git a/flang/unittests/Runtime/Inquiry.cpp b/FortranRuntime/unittests/Runtime/Inquiry.cpp
similarity index 98%
rename from flang/unittests/Runtime/Inquiry.cpp
rename to FortranRuntime/unittests/Runtime/Inquiry.cpp
index 3b523e992a3179..39303b7c809002 100644
--- a/flang/unittests/Runtime/Inquiry.cpp
+++ b/FortranRuntime/unittests/Runtime/Inquiry.cpp
@@ -1,4 +1,4 @@
-//===-- flang/unittests/Runtime/Inquiry.cpp -------------------------------===//
+//===-- unittests/Runtime/Inquiry.cpp ---------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/unittests/Runtime/ListInputTest.cpp b/FortranRuntime/unittests/Runtime/ListInputTest.cpp
similarity index 98%
rename from flang/unittests/Runtime/ListInputTest.cpp
rename to FortranRuntime/unittests/Runtime/ListInputTest.cpp
index a4eba5283add68..472838c25841c9 100644
--- a/flang/unittests/Runtime/ListInputTest.cpp
+++ b/FortranRuntime/unittests/Runtime/ListInputTest.cpp
@@ -1,4 +1,4 @@
-//===-- flang/unittests/Runtime/ListInputTest.cpp ---------------*- C++ -*-===//
+//===-- unittests/Runtime/ListInputTest.cpp ---------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -7,7 +7,7 @@
 //===----------------------------------------------------------------------===//
 
 #include "CrashHandlerFixture.h"
-#include "../../runtime/io-error.h"
+#include "../../lib/Runtime/io-error.h"
 #include "flang/Runtime/descriptor.h"
 #include "flang/Runtime/io-api.h"
 
diff --git a/flang/unittests/Runtime/LogicalFormatTest.cpp b/FortranRuntime/unittests/Runtime/LogicalFormatTest.cpp
similarity index 96%
rename from flang/unittests/Runtime/LogicalFormatTest.cpp
rename to FortranRuntime/unittests/Runtime/LogicalFormatTest.cpp
index a2c19d1e1ca948..928fddec50c874 100644
--- a/flang/unittests/Runtime/LogicalFormatTest.cpp
+++ b/FortranRuntime/unittests/Runtime/LogicalFormatTest.cpp
@@ -1,4 +1,4 @@
-//===-- flang/unittests/Runtime/LogicalFormatTest.cpp -----------*- C++ -*-===//
+//===-- unittests/Runtime/LogicalFormatTest.cpp -----------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/unittests/Runtime/Matmul.cpp b/FortranRuntime/unittests/Runtime/Matmul.cpp
similarity index 99%
rename from flang/unittests/Runtime/Matmul.cpp
rename to FortranRuntime/unittests/Runtime/Matmul.cpp
index c3fed9b972df2a..a37b618d3ab11a 100644
--- a/flang/unittests/Runtime/Matmul.cpp
+++ b/FortranRuntime/unittests/Runtime/Matmul.cpp
@@ -1,4 +1,4 @@
-//===-- flang/unittests/Runtime/Matmul.cpp--------- -------------*- C++ -*-===//
+//===-- unittests/Runtime/Matmul.cpp ----------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/unittests/Runtime/MatmulTranspose.cpp b/FortranRuntime/unittests/Runtime/MatmulTranspose.cpp
similarity index 99%
rename from flang/unittests/Runtime/MatmulTranspose.cpp
rename to FortranRuntime/unittests/Runtime/MatmulTranspose.cpp
index c582e945dc7c93..3483d1896e8bf6 100644
--- a/flang/unittests/Runtime/MatmulTranspose.cpp
+++ b/FortranRuntime/unittests/Runtime/MatmulTranspose.cpp
@@ -1,4 +1,4 @@
-//===-- flang/unittests/Runtime/MatmulTranspose.cpp -------------*- C++ -*-===//
+//===-- unittests/Runtime/MatmulTranspose.cpp -------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/unittests/Runtime/MiscIntrinsic.cpp b/FortranRuntime/unittests/Runtime/MiscIntrinsic.cpp
similarity index 98%
rename from flang/unittests/Runtime/MiscIntrinsic.cpp
rename to FortranRuntime/unittests/Runtime/MiscIntrinsic.cpp
index 7e19ed250bdc05..5672440c0e1b95 100644
--- a/flang/unittests/Runtime/MiscIntrinsic.cpp
+++ b/FortranRuntime/unittests/Runtime/MiscIntrinsic.cpp
@@ -1,4 +1,4 @@
-//===-- flang/unittests/Runtime/MiscIntrinsic.cpp ---------------*- C++ -*-===//
+//===-- unittests/Runtime/MiscIntrinsic.cpp ---------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/unittests/Runtime/Namelist.cpp b/FortranRuntime/unittests/Runtime/Namelist.cpp
similarity index 99%
rename from flang/unittests/Runtime/Namelist.cpp
rename to FortranRuntime/unittests/Runtime/Namelist.cpp
index 9037fa15a97cb3..729f9ffa5c7c10 100644
--- a/flang/unittests/Runtime/Namelist.cpp
+++ b/FortranRuntime/unittests/Runtime/Namelist.cpp
@@ -1,4 +1,4 @@
-//===-- flang/unittests/Runtime/Namelist.cpp --------------------*- C++ -*-===//
+//===-- unittests/Runtime/Namelist.cpp --------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -6,7 +6,7 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "../../runtime/namelist.h"
+#include "../../lib/Runtime/namelist.h"
 #include "CrashHandlerFixture.h"
 #include "tools.h"
 #include "flang/Runtime/descriptor.h"
diff --git a/flang/unittests/Runtime/Numeric.cpp b/FortranRuntime/unittests/Runtime/Numeric.cpp
similarity index 99%
rename from flang/unittests/Runtime/Numeric.cpp
rename to FortranRuntime/unittests/Runtime/Numeric.cpp
index 799756aab3839a..d15919b972bca7 100644
--- a/flang/unittests/Runtime/Numeric.cpp
+++ b/FortranRuntime/unittests/Runtime/Numeric.cpp
@@ -1,4 +1,4 @@
-//===-- flang/unittests/Runtime/Numeric.cpp ---------------------*- C++ -*-===//
+//===-- unittests/Runtime/Numeric.cpp ---------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/unittests/Runtime/NumericalFormatTest.cpp b/FortranRuntime/unittests/Runtime/NumericalFormatTest.cpp
similarity index 99%
rename from flang/unittests/Runtime/NumericalFormatTest.cpp
rename to FortranRuntime/unittests/Runtime/NumericalFormatTest.cpp
index f0055153203508..8a1dd6de1449b9 100644
--- a/flang/unittests/Runtime/NumericalFormatTest.cpp
+++ b/FortranRuntime/unittests/Runtime/NumericalFormatTest.cpp
@@ -1,4 +1,4 @@
-//===-- flang/unittests/Runtime/NumericalFormatTest.cpp ---------*- C++ -*-===//
+//===-- unittests/Runtime/NumericalFormatTest.cpp ---------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/unittests/Runtime/Pointer.cpp b/FortranRuntime/unittests/Runtime/Pointer.cpp
similarity index 98%
rename from flang/unittests/Runtime/Pointer.cpp
rename to FortranRuntime/unittests/Runtime/Pointer.cpp
index 4ce13ebc50a565..aa8545cdf951d1 100644
--- a/flang/unittests/Runtime/Pointer.cpp
+++ b/FortranRuntime/unittests/Runtime/Pointer.cpp
@@ -1,4 +1,4 @@
-//===-- flang/unittests/Runtime/Pointer.cpp--------- -------------*- C++-*-===//
+//===-- unittests/Runtime/Pointer.cpp ---------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/unittests/Runtime/Ragged.cpp b/FortranRuntime/unittests/Runtime/Ragged.cpp
similarity index 94%
rename from flang/unittests/Runtime/Ragged.cpp
rename to FortranRuntime/unittests/Runtime/Ragged.cpp
index 5049bc83405f17..feadd032f59bd4 100644
--- a/flang/unittests/Runtime/Ragged.cpp
+++ b/FortranRuntime/unittests/Runtime/Ragged.cpp
@@ -1,4 +1,4 @@
-//===-- flang/unittests/Runtime/Ragged.cpp ----------------------*- C++ -*-===//
+//===-- unittests/Runtime/Ragged.cpp ----------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/unittests/Runtime/Random.cpp b/FortranRuntime/unittests/Runtime/Random.cpp
similarity index 97%
rename from flang/unittests/Runtime/Random.cpp
rename to FortranRuntime/unittests/Runtime/Random.cpp
index cb739b94514290..c2300a478832ab 100644
--- a/flang/unittests/Runtime/Random.cpp
+++ b/FortranRuntime/unittests/Runtime/Random.cpp
@@ -1,4 +1,4 @@
-//===-- flang/unittests/Runtime/Random.cpp ----------------------*- C++ -*-===//
+//===-- unittests/Runtime/Random.cpp ----------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/unittests/Runtime/Reduction.cpp b/FortranRuntime/unittests/Runtime/Reduction.cpp
similarity index 99%
rename from flang/unittests/Runtime/Reduction.cpp
rename to FortranRuntime/unittests/Runtime/Reduction.cpp
index 25eb5fd760eadb..e8b5ac878871fd 100644
--- a/flang/unittests/Runtime/Reduction.cpp
+++ b/FortranRuntime/unittests/Runtime/Reduction.cpp
@@ -1,4 +1,4 @@
-//===-- flang/unittests/Runtime/Reductions.cpp ----------------------------===//
+//===-- unittests/Runtime/Reduction.cpp -------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/unittests/Runtime/RuntimeCrashTest.cpp b/FortranRuntime/unittests/Runtime/RuntimeCrashTest.cpp
similarity index 98%
rename from flang/unittests/Runtime/RuntimeCrashTest.cpp
rename to FortranRuntime/unittests/Runtime/RuntimeCrashTest.cpp
index a649051fdca0c5..7ce1ee796d739b 100644
--- a/flang/unittests/Runtime/RuntimeCrashTest.cpp
+++ b/FortranRuntime/unittests/Runtime/RuntimeCrashTest.cpp
@@ -1,4 +1,4 @@
-//===-- flang/unittests/Runtime/CrashHandlerFixture.cpp ---------*- C++ -*-===//
+//===-- unittests/Runtime/RuntimeCrashTest.cpp ------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -12,7 +12,7 @@
 //===----------------------------------------------------------------------===//
 #include "CrashHandlerFixture.h"
 #include "tools.h"
-#include "../../runtime/terminator.h"
+#include "../../lib/Runtime/terminator.h"
 #include "flang/Runtime/io-api.h"
 #include "flang/Runtime/transformational.h"
 #include <gtest/gtest.h>
diff --git a/flang/unittests/Runtime/Stop.cpp b/FortranRuntime/unittests/Runtime/Stop.cpp
similarity index 96%
rename from flang/unittests/Runtime/Stop.cpp
rename to FortranRuntime/unittests/Runtime/Stop.cpp
index b13602eaee5ea6..c12ec097068438 100644
--- a/flang/unittests/Runtime/Stop.cpp
+++ b/FortranRuntime/unittests/Runtime/Stop.cpp
@@ -1,4 +1,4 @@
-//===-- flang/unittests/Runtime/Stop.cpp ----------------------------------===//
+//===-- unittests/Runtime/Stop.cpp ------------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -11,7 +11,7 @@
 //===----------------------------------------------------------------------===//
 #include "flang/Runtime/stop.h"
 #include "CrashHandlerFixture.h"
-#include "../../runtime/environment.h"
+#include "../../lib/Runtime/environment.h"
 #include <cstdlib>
 #include <gtest/gtest.h>
 
diff --git a/flang/unittests/Runtime/Support.cpp b/FortranRuntime/unittests/Runtime/Support.cpp
similarity index 97%
rename from flang/unittests/Runtime/Support.cpp
rename to FortranRuntime/unittests/Runtime/Support.cpp
index 9d1a417fdbf426..b7aa39ef5523ba 100644
--- a/flang/unittests/Runtime/Support.cpp
+++ b/FortranRuntime/unittests/Runtime/Support.cpp
@@ -1,4 +1,4 @@
-//===-- flang/unittests/Runtime/Support.cpp ----------------------*- C++-*-===//
+//===-- unittests/Runtime/Support.cpp ---------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/unittests/Runtime/TemporaryStack.cpp b/FortranRuntime/unittests/Runtime/TemporaryStack.cpp
similarity index 98%
rename from flang/unittests/Runtime/TemporaryStack.cpp
rename to FortranRuntime/unittests/Runtime/TemporaryStack.cpp
index 0a9344969ca6ba..495c693b0493ef 100644
--- a/flang/unittests/Runtime/TemporaryStack.cpp
+++ b/FortranRuntime/unittests/Runtime/TemporaryStack.cpp
@@ -1,4 +1,4 @@
-//===--- flang/unittests/Runtime/TemporaryStack.cpp -------------*- C++ -*-===//
+//===-- unittests/Runtime/TemporaryStack.cpp --------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -8,7 +8,7 @@
 
 #include "gtest/gtest.h"
 #include "tools.h"
-#include "flang/ISO_Fortran_binding_wrapper.h"
+#include "flang/Common/ISO_Fortran_binding_wrapper.h"
 #include "flang/Runtime/allocatable.h"
 #include "flang/Runtime/cpp-type.h"
 #include "flang/Runtime/descriptor.h"
diff --git a/flang/unittests/Runtime/Time.cpp b/FortranRuntime/unittests/Runtime/Time.cpp
similarity index 98%
rename from flang/unittests/Runtime/Time.cpp
rename to FortranRuntime/unittests/Runtime/Time.cpp
index 9309d7b1ceffa0..548c0834e34a36 100644
--- a/flang/unittests/Runtime/Time.cpp
+++ b/FortranRuntime/unittests/Runtime/Time.cpp
@@ -1,4 +1,4 @@
-//===-- flang/unittests/Runtime/Time.cpp ----------------------------===//
+//===-- unittests/Runtime/Time.cpp ------------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/unittests/Runtime/Transformational.cpp b/FortranRuntime/unittests/Runtime/Transformational.cpp
similarity index 99%
rename from flang/unittests/Runtime/Transformational.cpp
rename to FortranRuntime/unittests/Runtime/Transformational.cpp
index 5836e70c740f9a..2dcab5a2aa8974 100644
--- a/flang/unittests/Runtime/Transformational.cpp
+++ b/FortranRuntime/unittests/Runtime/Transformational.cpp
@@ -1,4 +1,4 @@
-//===-- flang/unittests/Runtime/Transformational.cpp ----------------------===//
+//===-- unittests/Runtime/Transformational.cpp ------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/unittests/Runtime/tools.h b/FortranRuntime/unittests/Runtime/tools.h
similarity index 96%
rename from flang/unittests/Runtime/tools.h
rename to FortranRuntime/unittests/Runtime/tools.h
index 0347edace5c05c..a8e2096a90572e 100644
--- a/flang/unittests/Runtime/tools.h
+++ b/FortranRuntime/unittests/Runtime/tools.h
@@ -1,4 +1,4 @@
-//===-- flang/unittests/Runtime/tools.h -------------------------*- C++ -*-===//
+//===-- unittests/Runtime/tools.h -------------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index f58b816a9709dd..5e4057116a97cb 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -1291,7 +1291,7 @@ void tools::addOpenMPHostOffloadingArgs(const Compilation &C,
 /// Add Fortran runtime libs
 void tools::addFortranRuntimeLibs(const ToolChain &TC, const ArgList &Args,
                                   llvm::opt::ArgStringList &CmdArgs) {
-  // Link FortranRuntime and FortranDecimal
+  // Link FortranRuntime
   // These are handled earlier on Windows by telling the frontend driver to
   // add the correct libraries to link against as dependents in the object
   // file.
@@ -1308,7 +1308,6 @@ void tools::addFortranRuntimeLibs(const ToolChain &TC, const ArgList &Args,
         addAsNeededOption(TC, Args, CmdArgs, /*as_needed=*/false);
     }
     CmdArgs.push_back("-lFortranRuntime");
-    CmdArgs.push_back("-lFortranDecimal");
   }
 }
 
diff --git a/clang/lib/Driver/ToolChains/Flang.cpp b/clang/lib/Driver/ToolChains/Flang.cpp
index 6ce79d27e98c48..3619a8f4b81f08 100644
--- a/clang/lib/Driver/ToolChains/Flang.cpp
+++ b/clang/lib/Driver/ToolChains/Flang.cpp
@@ -309,21 +309,18 @@ static void processVSRuntimeLibrary(const ToolChain &TC, const ArgList &Args,
     CmdArgs.push_back("-D_MT");
     CmdArgs.push_back("--dependent-lib=libcmt");
     CmdArgs.push_back("--dependent-lib=FortranRuntime.static.lib");
-    CmdArgs.push_back("--dependent-lib=FortranDecimal.static.lib");
     break;
   case options::OPT__SLASH_MTd:
     CmdArgs.push_back("-D_MT");
     CmdArgs.push_back("-D_DEBUG");
     CmdArgs.push_back("--dependent-lib=libcmtd");
     CmdArgs.push_back("--dependent-lib=FortranRuntime.static_dbg.lib");
-    CmdArgs.push_back("--dependent-lib=FortranDecimal.static_dbg.lib");
     break;
   case options::OPT__SLASH_MD:
     CmdArgs.push_back("-D_MT");
     CmdArgs.push_back("-D_DLL");
     CmdArgs.push_back("--dependent-lib=msvcrt");
     CmdArgs.push_back("--dependent-lib=FortranRuntime.dynamic.lib");
-    CmdArgs.push_back("--dependent-lib=FortranDecimal.dynamic.lib");
     break;
   case options::OPT__SLASH_MDd:
     CmdArgs.push_back("-D_MT");
@@ -331,7 +328,6 @@ static void processVSRuntimeLibrary(const ToolChain &TC, const ArgList &Args,
     CmdArgs.push_back("-D_DLL");
     CmdArgs.push_back("--dependent-lib=msvcrtd");
     CmdArgs.push_back("--dependent-lib=FortranRuntime.dynamic_dbg.lib");
-    CmdArgs.push_back("--dependent-lib=FortranDecimal.dynamic_dbg.lib");
     break;
   }
 }
diff --git a/flang/CMakeLists.txt b/flang/CMakeLists.txt
index 971e5d5c93f231..00e570798bb412 100644
--- a/flang/CMakeLists.txt
+++ b/flang/CMakeLists.txt
@@ -23,6 +23,7 @@ if (LLVM_ENABLE_EH)
 endif()
 
 set(FLANG_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
+set(FORTRANRUNTIME_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../FortranRuntime")
 
 if (CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR AND NOT MSVC_IDE)
   message(FATAL_ERROR "In-source builds are not allowed. \
@@ -34,17 +35,6 @@ endif()
 
 option(FLANG_ENABLE_WERROR "Fail and stop building flang if a warning is triggered." OFF)
 
-# The out of tree builds of the compiler and the Fortran runtime
-# must use the same setting of FLANG_RUNTIME_F128_MATH_LIB
-# to be composable. Failure to synchronize this setting may result
-# in linking errors or fatal failures in F128 runtime functions.
-set(FLANG_RUNTIME_F128_MATH_LIB "" CACHE STRING
-  "Specifies the target library used for implementing IEEE-754 128-bit float \
-  math in F18 runtime, e.g. it might be libquadmath for targets where \
-  REAL(16) is mapped to __float128, or libm for targets where REAL(16) \
-  is mapped to long double, etc."
-  )
-
 # Check for a standalone build and configure as appropriate from
 # there.
 if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
@@ -170,7 +160,6 @@ if (FLANG_STANDALONE_BUILD)
 
   link_directories("${LLVM_LIBRARY_DIR}")
 
-  set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
   set(CMAKE_LIBRARY_OUTPUT_DIRECTORY
     ${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX})
   set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY
@@ -249,7 +238,6 @@ include_directories(SYSTEM ${CLANG_INCLUDE_DIR})
 
 # tco tool and FIR lib output directories
 if(FLANG_STANDALONE_BUILD)
-  set(LLVM_RUNTIME_OUTPUT_INTDIR ${CMAKE_BINARY_DIR}/bin)
   set(LLVM_LIBRARY_OUTPUT_INTDIR ${CMAKE_BINARY_DIR}/lib)
 endif()
 # Always build tco tool
@@ -257,7 +245,8 @@ set(LLVM_BUILD_TOOLS ON)
 
 include_directories(BEFORE
   ${FLANG_BINARY_DIR}/include
-  ${FLANG_SOURCE_DIR}/include)
+  ${FLANG_SOURCE_DIR}/include
+  ${FORTRANRUNTIME_SOURCE_DIR}/include)
 
 # Add Flang-centric modules to cmake path.
 list(INSERT CMAKE_MODULE_PATH 0
@@ -335,12 +324,6 @@ if (FLANG_REPOSITORY_STRING)
   add_definitions(-DFLANG_REPOSITORY_STRING="${FLANG_REPOSITORY_STRING}")
 endif()
 
-if (FLANG_RUNTIME_F128_MATH_LIB)
-  add_compile_definitions(
-    FLANG_RUNTIME_F128_MATH_LIB="${FLANG_RUNTIME_F128_MATH_LIB}"
-    )
-endif()
-
 include(TestBigEndian)
 test_big_endian(IS_BIGENDIAN)
 if (IS_BIGENDIAN)
@@ -462,14 +445,6 @@ if (FLANG_BUILD_TOOLS)
   add_subdirectory(tools)
 endif()
 
-option(FLANG_CUF_RUNTIME
-  "Compile CUDA Fortran runtime sources" OFF)
-if (FLANG_CUF_RUNTIME)
-  find_package(CUDAToolkit REQUIRED)
-endif()
-
-add_subdirectory(runtime)
-
 if (LLVM_INCLUDE_EXAMPLES)
   add_subdirectory(examples)
 endif()
@@ -532,17 +507,3 @@ if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
     )
 endif()
 
-# Put ISO_Fortran_binding.h into the include files of the build area now
-# so that we can run tests before installing
-include(GetClangResourceDir)
-get_clang_resource_dir(HEADER_BINARY_DIR PREFIX ${LLVM_LIBRARY_OUTPUT_INTDIR}/.. SUBDIR include)
-configure_file(
-  ${FLANG_SOURCE_DIR}/include/flang/ISO_Fortran_binding.h
-  ${HEADER_BINARY_DIR}/ISO_Fortran_binding.h)
-
-# And also install it into the install area
-get_clang_resource_dir(HEADER_INSTALL_DIR SUBDIR include)
-install(
-  FILES include/flang/ISO_Fortran_binding.h
-  DESTINATION ${HEADER_INSTALL_DIR} )
-
diff --git a/flang/docs/FlangDriver.md b/flang/docs/FlangDriver.md
index e1c11062125028..98611ee338e706 100644
--- a/flang/docs/FlangDriver.md
+++ b/flang/docs/FlangDriver.md
@@ -179,19 +179,18 @@ like this:
 
 ```
 $ flang -v -o example example.o
-"/usr/bin/ld" [...] example.o [...] "-lFortranRuntime" "-lFortranDecimal" [...]
+"/usr/bin/ld" [...] example.o [...] "-lFortranRuntime" [...]
 ```
 
 The automatically added libraries are:
 
 * `FortranRuntime`: Provides most of the Flang runtime library.
-* `FortranDecimal`: Provides operations for decimal numbers.
 
 If the code is C/C++ based and invokes Fortran routines, one can either use Clang
 or Flang as the linker driver.  If Clang is used, it will automatically all
 required runtime libraries needed by C++ (e.g., for STL) to the linker invocation.
 In this case, one has to explicitly provide the Fortran runtime libraries
-`FortranRuntime` and/or `FortranDecimal`.  An alternative is to use Flang to link.
+`FortranRuntime`.  An alternative is to use Flang to link.
 In this case, it may be required to explicitly supply C++ runtime libraries.
 
 On Darwin, the logical root where the system libraries are located (sysroot)
diff --git a/flang/include/flang/Evaluate/call.h b/flang/include/flang/Evaluate/call.h
index 7531d8a81e808d..8137185da61442 100644
--- a/flang/include/flang/Evaluate/call.h
+++ b/flang/include/flang/Evaluate/call.h
@@ -13,9 +13,9 @@
 #include "constant.h"
 #include "formatting.h"
 #include "type.h"
-#include "flang/Common/Fortran.h"
-#include "flang/Common/indirection.h"
-#include "flang/Common/reference.h"
+#include "flang/Support/Fortran.h"
+#include "flang/Support/indirection.h"
+#include "flang/Support/reference.h"
 #include "flang/Parser/char-block.h"
 #include "flang/Semantics/attr.h"
 #include <optional>
diff --git a/flang/include/flang/Evaluate/characteristics.h b/flang/include/flang/Evaluate/characteristics.h
index 11533a7259b055..8f1e6876d88d58 100644
--- a/flang/include/flang/Evaluate/characteristics.h
+++ b/flang/include/flang/Evaluate/characteristics.h
@@ -18,11 +18,11 @@
 #include "shape.h"
 #include "tools.h"
 #include "type.h"
-#include "flang/Common/Fortran-features.h"
-#include "flang/Common/Fortran.h"
+#include "flang/Support/Fortran-features.h"
+#include "flang/Support/Fortran.h"
 #include "flang/Common/enum-set.h"
 #include "flang/Common/idioms.h"
-#include "flang/Common/indirection.h"
+#include "flang/Support/indirection.h"
 #include "flang/Parser/char-block.h"
 #include "flang/Semantics/symbol.h"
 #include <optional>
diff --git a/flang/include/flang/Evaluate/common.h b/flang/include/flang/Evaluate/common.h
index d493e5fe044173..69f09a930dc604 100644
--- a/flang/include/flang/Evaluate/common.h
+++ b/flang/include/flang/Evaluate/common.h
@@ -9,15 +9,17 @@
 #ifndef FORTRAN_EVALUATE_COMMON_H_
 #define FORTRAN_EVALUATE_COMMON_H_
 
-#include "flang/Common/Fortran-features.h"
-#include "flang/Common/Fortran.h"
-#include "flang/Common/default-kinds.h"
+#include "flang/Support/Fortran-features.h"
+#include "flang/Support/Fortran.h"
+#include "flang/Support/default-kinds.h"
 #include "flang/Common/enum-set.h"
 #include "flang/Common/idioms.h"
-#include "flang/Common/indirection.h"
+#include "flang/Support/indirection.h"
+#include "flang/Common/Fortran-consts.h"
 #include "flang/Common/restorer.h"
 #include "flang/Parser/char-block.h"
 #include "flang/Parser/message.h"
+#include "flang/Common/target-rounding.h"
 #include <cinttypes>
 #include <map>
 #include <set>
@@ -33,6 +35,9 @@ class TargetCharacteristics;
 
 using common::ConstantSubscript;
 using common::RelationalOperator;
+using common::RoundingMode;
+using common::RealFlags;
+using common::RealFlag;
 
 // Integers are always ordered; reals may not be.
 ENUM_CLASS(Ordering, Less, Equal, Greater)
@@ -128,11 +133,6 @@ static constexpr bool Satisfies(RelationalOperator op, Relation relation) {
   return false; // silence g++ warning
 }
 
-// These are ordered like the bits in a common fenv.h header file.
-ENUM_CLASS(RealFlag, InvalidArgument, Denorm, DivideByZero, Overflow, Underflow,
-    Inexact)
-using RealFlags = common::EnumSet<RealFlag, RealFlag_enumSize>;
-
 template <typename A> struct ValueWithRealFlags {
   A AccumulateFlags(RealFlags &f) {
     f |= flags;
diff --git a/flang/include/flang/Evaluate/constant.h b/flang/include/flang/Evaluate/constant.h
index d9866a08889f35..a171b10026409c 100644
--- a/flang/include/flang/Evaluate/constant.h
+++ b/flang/include/flang/Evaluate/constant.h
@@ -11,8 +11,8 @@
 
 #include "formatting.h"
 #include "type.h"
-#include "flang/Common/default-kinds.h"
-#include "flang/Common/reference.h"
+#include "flang/Support/default-kinds.h"
+#include "flang/Support/reference.h"
 #include <map>
 #include <vector>
 
diff --git a/flang/include/flang/Evaluate/expression.h b/flang/include/flang/Evaluate/expression.h
index 2a40193e32306b..a582a2ea1a6989 100644
--- a/flang/include/flang/Evaluate/expression.h
+++ b/flang/include/flang/Evaluate/expression.h
@@ -21,10 +21,10 @@
 #include "formatting.h"
 #include "type.h"
 #include "variable.h"
-#include "flang/Common/Fortran.h"
+#include "flang/Support/Fortran.h"
 #include "flang/Common/idioms.h"
-#include "flang/Common/indirection.h"
-#include "flang/Common/template.h"
+#include "flang/Support/indirection.h"
+#include "flang/Support/template.h"
 #include "flang/Parser/char-block.h"
 #include <algorithm>
 #include <list>
diff --git a/flang/include/flang/Evaluate/formatting.h b/flang/include/flang/Evaluate/formatting.h
index aa82f56107fdd3..ae9351139b1933 100644
--- a/flang/include/flang/Evaluate/formatting.h
+++ b/flang/include/flang/Evaluate/formatting.h
@@ -19,7 +19,7 @@
 // This header is meant to be included by the headers that define the several
 // representational class templates that need it, not by external clients.
 
-#include "flang/Common/indirection.h"
+#include "flang/Support/indirection.h"
 #include "llvm/Support/raw_ostream.h"
 #include <optional>
 #include <type_traits>
diff --git a/flang/include/flang/Evaluate/intrinsics.h b/flang/include/flang/Evaluate/intrinsics.h
index 15afb772ae767b..17f555445f6f79 100644
--- a/flang/include/flang/Evaluate/intrinsics.h
+++ b/flang/include/flang/Evaluate/intrinsics.h
@@ -12,7 +12,7 @@
 #include "call.h"
 #include "characteristics.h"
 #include "type.h"
-#include "flang/Common/default-kinds.h"
+#include "flang/Support/default-kinds.h"
 #include "flang/Parser/char-block.h"
 #include "flang/Parser/message.h"
 #include <memory>
diff --git a/flang/include/flang/Evaluate/shape.h b/flang/include/flang/Evaluate/shape.h
index e33044c0d34e56..f3eeea7984bba7 100644
--- a/flang/include/flang/Evaluate/shape.h
+++ b/flang/include/flang/Evaluate/shape.h
@@ -15,7 +15,7 @@
 #include "expression.h"
 #include "traverse.h"
 #include "variable.h"
-#include "flang/Common/indirection.h"
+#include "flang/Support/indirection.h"
 #include "flang/Evaluate/type.h"
 #include <optional>
 #include <variant>
diff --git a/flang/include/flang/Evaluate/target.h b/flang/include/flang/Evaluate/target.h
index d076fcbf083078..8f52b29bec6654 100644
--- a/flang/include/flang/Evaluate/target.h
+++ b/flang/include/flang/Evaluate/target.h
@@ -12,27 +12,16 @@
 #ifndef FORTRAN_EVALUATE_TARGET_H_
 #define FORTRAN_EVALUATE_TARGET_H_
 
-#include "flang/Common/Fortran.h"
+#include "flang/Support/Fortran.h"
 #include "flang/Common/enum-class.h"
 #include "flang/Common/enum-set.h"
+#include "flang/Common/target-rounding.h"
 #include "flang/Evaluate/common.h"
 #include <cstdint>
 
 namespace Fortran::evaluate {
 
-// Floating-point rounding control
-struct Rounding {
-  common::RoundingMode mode{common::RoundingMode::TiesToEven};
-  // When set, emulate status flag behavior peculiar to x86
-  // (viz., fail to set the Underflow flag when an inexact product of a
-  // multiplication is rounded up to a normal number from a subnormal
-  // in some rounding modes)
-#if __x86_64__ || __riscv || __loongarch__
-  bool x86CompatibleBehavior{true};
-#else
-  bool x86CompatibleBehavior{false};
-#endif
-};
+using common::Rounding;
 
 ENUM_CLASS(IeeeFeature, Denormal, Divide, Flags, Halting, Inf, Io, NaN,
     Rounding, Sqrt, Standard, Subnormal, UnderflowControl)
diff --git a/flang/include/flang/Evaluate/tools.h b/flang/include/flang/Evaluate/tools.h
index a0487e399d936c..29d19bff44c79c 100644
--- a/flang/include/flang/Evaluate/tools.h
+++ b/flang/include/flang/Evaluate/tools.h
@@ -11,8 +11,8 @@
 
 #include "traverse.h"
 #include "flang/Common/idioms.h"
-#include "flang/Common/template.h"
-#include "flang/Common/unwrap.h"
+#include "flang/Support/template.h"
+#include "flang/Support/unwrap.h"
 #include "flang/Evaluate/constant.h"
 #include "flang/Evaluate/expression.h"
 #include "flang/Evaluate/shape.h"
diff --git a/flang/include/flang/Evaluate/traverse.h b/flang/include/flang/Evaluate/traverse.h
index 7f4a67d97e64e7..e04888f395c013 100644
--- a/flang/include/flang/Evaluate/traverse.h
+++ b/flang/include/flang/Evaluate/traverse.h
@@ -38,7 +38,7 @@
 // expression of an ASSOCIATE (or related) construct entity.
 
 #include "expression.h"
-#include "flang/Common/indirection.h"
+#include "flang/Support/indirection.h"
 #include "flang/Semantics/symbol.h"
 #include "flang/Semantics/type.h"
 #include <set>
diff --git a/flang/include/flang/Evaluate/type.h b/flang/include/flang/Evaluate/type.h
index bd8887dbce4e82..b68a5790c810fd 100644
--- a/flang/include/flang/Evaluate/type.h
+++ b/flang/include/flang/Evaluate/type.h
@@ -22,11 +22,11 @@
 #include "integer.h"
 #include "logical.h"
 #include "real.h"
-#include "flang/Common/Fortran-features.h"
-#include "flang/Common/Fortran.h"
+#include "flang/Support/Fortran-features.h"
+#include "flang/Support/Fortran.h"
 #include "flang/Common/idioms.h"
 #include "flang/Common/real.h"
-#include "flang/Common/template.h"
+#include "flang/Support/template.h"
 #include <cinttypes>
 #include <optional>
 #include <string>
diff --git a/flang/include/flang/Evaluate/variable.h b/flang/include/flang/Evaluate/variable.h
index 9565826dbfaea4..8d0da5b24277cd 100644
--- a/flang/include/flang/Evaluate/variable.h
+++ b/flang/include/flang/Evaluate/variable.h
@@ -21,8 +21,8 @@
 #include "static-data.h"
 #include "type.h"
 #include "flang/Common/idioms.h"
-#include "flang/Common/reference.h"
-#include "flang/Common/template.h"
+#include "flang/Support/reference.h"
+#include "flang/Support/template.h"
 #include "flang/Parser/char-block.h"
 #include <optional>
 #include <variant>
diff --git a/flang/include/flang/Frontend/FrontendOptions.h b/flang/include/flang/Frontend/FrontendOptions.h
index 82ca99672ec610..b69ffe83de1707 100644
--- a/flang/include/flang/Frontend/FrontendOptions.h
+++ b/flang/include/flang/Frontend/FrontendOptions.h
@@ -13,7 +13,7 @@
 #ifndef FORTRAN_FRONTEND_FRONTENDOPTIONS_H
 #define FORTRAN_FRONTEND_FRONTENDOPTIONS_H
 
-#include "flang/Common/Fortran-features.h"
+#include "flang/Support/Fortran-features.h"
 #include "flang/Lower/EnvironmentDefault.h"
 #include "flang/Parser/characters.h"
 #include "flang/Parser/unparse.h"
diff --git a/flang/include/flang/Lower/AbstractConverter.h b/flang/include/flang/Lower/AbstractConverter.h
index daded9091780e2..56646c196a7de5 100644
--- a/flang/include/flang/Lower/AbstractConverter.h
+++ b/flang/include/flang/Lower/AbstractConverter.h
@@ -13,7 +13,7 @@
 #ifndef FORTRAN_LOWER_ABSTRACTCONVERTER_H
 #define FORTRAN_LOWER_ABSTRACTCONVERTER_H
 
-#include "flang/Common/Fortran.h"
+#include "flang/Support/Fortran.h"
 #include "flang/Lower/LoweringOptions.h"
 #include "flang/Lower/PFTDefs.h"
 #include "flang/Optimizer/Builder/BoxValue.h"
diff --git a/flang/include/flang/Lower/Bridge.h b/flang/include/flang/Lower/Bridge.h
index 4379ed512cdf0a..0c2c7abc324952 100644
--- a/flang/include/flang/Lower/Bridge.h
+++ b/flang/include/flang/Lower/Bridge.h
@@ -13,7 +13,7 @@
 #ifndef FORTRAN_LOWER_BRIDGE_H
 #define FORTRAN_LOWER_BRIDGE_H
 
-#include "flang/Common/Fortran.h"
+#include "flang/Support/Fortran.h"
 #include "flang/Lower/AbstractConverter.h"
 #include "flang/Lower/EnvironmentDefault.h"
 #include "flang/Lower/LoweringOptions.h"
diff --git a/flang/include/flang/Lower/CallInterface.h b/flang/include/flang/Lower/CallInterface.h
index 9a688330e8bd2d..df01eafe679d7d 100644
--- a/flang/include/flang/Lower/CallInterface.h
+++ b/flang/include/flang/Lower/CallInterface.h
@@ -27,7 +27,7 @@
 #ifndef FORTRAN_LOWER_CALLINTERFACE_H
 #define FORTRAN_LOWER_CALLINTERFACE_H
 
-#include "flang/Common/reference.h"
+#include "flang/Support/reference.h"
 #include "flang/Evaluate/characteristics.h"
 #include "mlir/Dialect/Func/IR/FuncOps.h"
 #include "mlir/IR/BuiltinOps.h"
diff --git a/flang/include/flang/Lower/ConvertType.h b/flang/include/flang/Lower/ConvertType.h
index 7a3f92649a4e4a..b889d2bb279de2 100644
--- a/flang/include/flang/Lower/ConvertType.h
+++ b/flang/include/flang/Lower/ConvertType.h
@@ -21,7 +21,7 @@
 #ifndef FORTRAN_LOWER_CONVERT_TYPE_H
 #define FORTRAN_LOWER_CONVERT_TYPE_H
 
-#include "flang/Common/Fortran.h"
+#include "flang/Support/Fortran.h"
 #include "flang/Evaluate/type.h"
 #include "mlir/IR/BuiltinTypes.h"
 
diff --git a/flang/include/flang/Lower/LoweringOptions.h b/flang/include/flang/Lower/LoweringOptions.h
index 8105ccd7ef6b15..171510393b8168 100644
--- a/flang/include/flang/Lower/LoweringOptions.h
+++ b/flang/include/flang/Lower/LoweringOptions.h
@@ -15,7 +15,7 @@
 #ifndef FLANG_LOWER_LOWERINGOPTIONS_H
 #define FLANG_LOWER_LOWERINGOPTIONS_H
 
-#include "flang/Common/MathOptionsBase.h"
+#include "flang/Support/MathOptionsBase.h"
 
 namespace Fortran::lower {
 
diff --git a/flang/include/flang/Lower/PFTBuilder.h b/flang/include/flang/Lower/PFTBuilder.h
index 7f1b93c564b4c4..7ee61e630581fe 100644
--- a/flang/include/flang/Lower/PFTBuilder.h
+++ b/flang/include/flang/Lower/PFTBuilder.h
@@ -17,8 +17,8 @@
 #ifndef FORTRAN_LOWER_PFTBUILDER_H
 #define FORTRAN_LOWER_PFTBUILDER_H
 
-#include "flang/Common/reference.h"
-#include "flang/Common/template.h"
+#include "flang/Support/reference.h"
+#include "flang/Support/template.h"
 #include "flang/Lower/HostAssociations.h"
 #include "flang/Lower/PFTDefs.h"
 #include "flang/Parser/parse-tree.h"
diff --git a/flang/include/flang/Lower/Support/Utils.h b/flang/include/flang/Lower/Support/Utils.h
index 1cc74521e22d88..a09cfb16f7805a 100644
--- a/flang/include/flang/Lower/Support/Utils.h
+++ b/flang/include/flang/Lower/Support/Utils.h
@@ -13,7 +13,7 @@
 #ifndef FORTRAN_LOWER_SUPPORT_UTILS_H
 #define FORTRAN_LOWER_SUPPORT_UTILS_H
 
-#include "flang/Common/indirection.h"
+#include "flang/Support/indirection.h"
 #include "flang/Parser/char-block.h"
 #include "flang/Semantics/tools.h"
 #include "mlir/Dialect/Arith/IR/Arith.h"
diff --git a/flang/include/flang/Lower/SymbolMap.h b/flang/include/flang/Lower/SymbolMap.h
index c03f9afd40801c..7bba02e41a3bdf 100644
--- a/flang/include/flang/Lower/SymbolMap.h
+++ b/flang/include/flang/Lower/SymbolMap.h
@@ -13,7 +13,7 @@
 #ifndef FORTRAN_LOWER_SYMBOLMAP_H
 #define FORTRAN_LOWER_SYMBOLMAP_H
 
-#include "flang/Common/reference.h"
+#include "flang/Support/reference.h"
 #include "flang/Optimizer/Builder/BoxValue.h"
 #include "flang/Optimizer/Dialect/FIRType.h"
 #include "flang/Optimizer/Dialect/FortranVariableInterface.h"
diff --git a/flang/include/flang/Optimizer/Builder/FIRBuilder.h b/flang/include/flang/Optimizer/Builder/FIRBuilder.h
index f7151f26f09cb3..90279417b5c939 100644
--- a/flang/include/flang/Optimizer/Builder/FIRBuilder.h
+++ b/flang/include/flang/Optimizer/Builder/FIRBuilder.h
@@ -16,7 +16,7 @@
 #ifndef FORTRAN_OPTIMIZER_BUILDER_FIRBUILDER_H
 #define FORTRAN_OPTIMIZER_BUILDER_FIRBUILDER_H
 
-#include "flang/Common/MathOptionsBase.h"
+#include "flang/Support/MathOptionsBase.h"
 #include "flang/Optimizer/Dialect/FIROps.h"
 #include "flang/Optimizer/Dialect/FIROpsSupport.h"
 #include "flang/Optimizer/Dialect/FIRType.h"
diff --git a/flang/include/flang/Optimizer/Builder/IntrinsicCall.h b/flang/include/flang/Optimizer/Builder/IntrinsicCall.h
index 78bb82b17d4050..3fc4201bd16c6c 100644
--- a/flang/include/flang/Optimizer/Builder/IntrinsicCall.h
+++ b/flang/include/flang/Optimizer/Builder/IntrinsicCall.h
@@ -397,6 +397,7 @@ struct IntrinsicLibrary {
   fir::ExtendedValue genUbound(mlir::Type, llvm::ArrayRef<fir::ExtendedValue>);
   fir::ExtendedValue genUnpack(mlir::Type, llvm::ArrayRef<fir::ExtendedValue>);
   fir::ExtendedValue genVerify(mlir::Type, llvm::ArrayRef<fir::ExtendedValue>);
+    fir::ExtendedValue genNumericStorageSize(mlir::Type, llvm::ArrayRef<fir::ExtendedValue>);
 
   /// Implement all conversion functions like DBLE, the first argument is
   /// the value to convert. There may be an additional KIND arguments that
diff --git a/flang/include/flang/Optimizer/Builder/PPCIntrinsicCall.h b/flang/include/flang/Optimizer/Builder/PPCIntrinsicCall.h
index a7c4c075d818ee..26cf34188eb568 100644
--- a/flang/include/flang/Optimizer/Builder/PPCIntrinsicCall.h
+++ b/flang/include/flang/Optimizer/Builder/PPCIntrinsicCall.h
@@ -9,7 +9,7 @@
 #ifndef FORTRAN_LOWER_PPCINTRINSICCALL_H
 #define FORTRAN_LOWER_PPCINTRINSICCALL_H
 
-#include "flang/Common/static-multimap-view.h"
+#include "flang/Support/static-multimap-view.h"
 #include "flang/Optimizer/Builder/IntrinsicCall.h"
 #include "mlir/Dialect/Math/IR/Math.h"
 
diff --git a/flang/include/flang/Optimizer/Builder/Runtime/RTBuilder.h b/flang/include/flang/Optimizer/Builder/Runtime/RTBuilder.h
index a103861f1510b8..104e363e689857 100644
--- a/flang/include/flang/Optimizer/Builder/Runtime/RTBuilder.h
+++ b/flang/include/flang/Optimizer/Builder/Runtime/RTBuilder.h
@@ -17,7 +17,7 @@
 #ifndef FORTRAN_OPTIMIZER_BUILDER_RUNTIME_RTBUILDER_H
 #define FORTRAN_OPTIMIZER_BUILDER_RUNTIME_RTBUILDER_H
 
-#include "flang/Common/Fortran.h"
+#include "flang/Support/Fortran.h"
 #include "flang/Common/uint128.h"
 #include "flang/Optimizer/Builder/FIRBuilder.h"
 #include "flang/Optimizer/Dialect/FIRDialect.h"
diff --git a/flang/include/flang/Optimizer/CodeGen/DescriptorModel.h b/flang/include/flang/Optimizer/CodeGen/DescriptorModel.h
index ff0cf29e8073e6..31d1416846d0c9 100644
--- a/flang/include/flang/Optimizer/CodeGen/DescriptorModel.h
+++ b/flang/include/flang/Optimizer/CodeGen/DescriptorModel.h
@@ -22,7 +22,7 @@
 #ifndef OPTIMIZER_DESCRIPTOR_MODEL_H
 #define OPTIMIZER_DESCRIPTOR_MODEL_H
 
-#include "flang/ISO_Fortran_binding_wrapper.h"
+#include "flang/Common/ISO_Fortran_binding_wrapper.h"
 #include "flang/Runtime/descriptor.h"
 #include "mlir/Dialect/LLVMIR/LLVMTypes.h"
 #include "mlir/IR/BuiltinTypes.h"
diff --git a/flang/include/flang/Optimizer/Dialect/CUF/Attributes/CUFAttr.h b/flang/include/flang/Optimizer/Dialect/CUF/Attributes/CUFAttr.h
index f32e39b543e3f7..85615a4d69157d 100644
--- a/flang/include/flang/Optimizer/Dialect/CUF/Attributes/CUFAttr.h
+++ b/flang/include/flang/Optimizer/Dialect/CUF/Attributes/CUFAttr.h
@@ -13,7 +13,7 @@
 #ifndef FORTRAN_OPTIMIZER_DIALECT_CUF_CUFATTR_H
 #define FORTRAN_OPTIMIZER_DIALECT_CUF_CUFATTR_H
 
-#include "flang/Common/Fortran.h"
+#include "flang/Support/Fortran.h"
 #include "mlir/IR/BuiltinAttributes.h"
 
 namespace llvm {
diff --git a/flang/include/flang/Optimizer/Support/TypeCode.h b/flang/include/flang/Optimizer/Support/TypeCode.h
index 308c82118d5020..ec21d672287e62 100644
--- a/flang/include/flang/Optimizer/Support/TypeCode.h
+++ b/flang/include/flang/Optimizer/Support/TypeCode.h
@@ -13,7 +13,7 @@
 #ifndef FORTRAN_OPTIMIZER_SUPPORT_TYPECODE_H
 #define FORTRAN_OPTIMIZER_SUPPORT_TYPECODE_H
 
-#include "flang/ISO_Fortran_binding_wrapper.h"
+#include "flang/Common/ISO_Fortran_binding_wrapper.h"
 #include "llvm/Support/ErrorHandling.h"
 
 namespace fir {
diff --git a/flang/include/flang/Optimizer/Support/Utils.h b/flang/include/flang/Optimizer/Support/Utils.h
index 02bec4164fca08..631322b34c49e5 100644
--- a/flang/include/flang/Optimizer/Support/Utils.h
+++ b/flang/include/flang/Optimizer/Support/Utils.h
@@ -13,7 +13,7 @@
 #ifndef FORTRAN_OPTIMIZER_SUPPORT_UTILS_H
 #define FORTRAN_OPTIMIZER_SUPPORT_UTILS_H
 
-#include "flang/Common/default-kinds.h"
+#include "flang/Support/default-kinds.h"
 #include "flang/Optimizer/Builder/FIRBuilder.h"
 #include "flang/Optimizer/Builder/Todo.h"
 #include "flang/Optimizer/Dialect/CUF/Attributes/CUFAttr.h"
diff --git a/flang/include/flang/Parser/char-block.h b/flang/include/flang/Parser/char-block.h
index 38f4f7b82e1eae..4541b31e566f95 100644
--- a/flang/include/flang/Parser/char-block.h
+++ b/flang/include/flang/Parser/char-block.h
@@ -11,7 +11,7 @@
 
 // Describes a contiguous block of characters; does not own their storage.
 
-#include "flang/Common/interval.h"
+#include "flang/Support/interval.h"
 #include <algorithm>
 #include <cstddef>
 #include <cstring>
diff --git a/flang/include/flang/Parser/dump-parse-tree.h b/flang/include/flang/Parser/dump-parse-tree.h
index 37c3370b48a085..f98ac17b6ecba7 100644
--- a/flang/include/flang/Parser/dump-parse-tree.h
+++ b/flang/include/flang/Parser/dump-parse-tree.h
@@ -14,9 +14,9 @@
 #include "parse-tree.h"
 #include "tools.h"
 #include "unparse.h"
-#include "flang/Common/Fortran.h"
+#include "flang/Support/Fortran.h"
 #include "flang/Common/idioms.h"
-#include "flang/Common/indirection.h"
+#include "flang/Support/indirection.h"
 #include "llvm/Support/raw_ostream.h"
 #include <string>
 #include <type_traits>
diff --git a/flang/include/flang/Parser/message.h b/flang/include/flang/Parser/message.h
index 668559aeec9478..70746bf551f2d7 100644
--- a/flang/include/flang/Parser/message.h
+++ b/flang/include/flang/Parser/message.h
@@ -16,7 +16,7 @@
 #include "char-set.h"
 #include "provenance.h"
 #include "flang/Common/idioms.h"
-#include "flang/Common/reference-counted.h"
+#include "flang/Support/reference-counted.h"
 #include "flang/Common/restorer.h"
 #include <cstddef>
 #include <cstring>
diff --git a/flang/include/flang/Parser/parse-state.h b/flang/include/flang/Parser/parse-state.h
index 76cbb3470dc08d..20d339aeeccccf 100644
--- a/flang/include/flang/Parser/parse-state.h
+++ b/flang/include/flang/Parser/parse-state.h
@@ -16,7 +16,7 @@
 // and recovery during parsing!
 
 #include "user-state.h"
-#include "flang/Common/Fortran-features.h"
+#include "flang/Support/Fortran-features.h"
 #include "flang/Common/idioms.h"
 #include "flang/Parser/characters.h"
 #include "flang/Parser/message.h"
diff --git a/flang/include/flang/Parser/parse-tree.h b/flang/include/flang/Parser/parse-tree.h
index 548fcc81984b2a..a6d19dd6435966 100644
--- a/flang/include/flang/Parser/parse-tree.h
+++ b/flang/include/flang/Parser/parse-tree.h
@@ -22,9 +22,9 @@
 #include "format-specification.h"
 #include "message.h"
 #include "provenance.h"
-#include "flang/Common/Fortran.h"
+#include "flang/Support/Fortran.h"
 #include "flang/Common/idioms.h"
-#include "flang/Common/indirection.h"
+#include "flang/Support/indirection.h"
 #include "llvm/Frontend/OpenACC/ACC.h.inc"
 #include "llvm/Frontend/OpenMP/OMPConstants.h"
 #include <cinttypes>
diff --git a/flang/include/flang/Parser/parsing.h b/flang/include/flang/Parser/parsing.h
index 4d329c189cb80e..b0de98737f536e 100644
--- a/flang/include/flang/Parser/parsing.h
+++ b/flang/include/flang/Parser/parsing.h
@@ -14,7 +14,7 @@
 #include "message.h"
 #include "parse-tree.h"
 #include "provenance.h"
-#include "flang/Common/Fortran-features.h"
+#include "flang/Support/Fortran-features.h"
 #include "flang/Parser/preprocessor.h"
 #include "llvm/Support/raw_ostream.h"
 #include <optional>
diff --git a/flang/include/flang/Parser/provenance.h b/flang/include/flang/Parser/provenance.h
index a9224b727fd054..7f29fb272c9421 100644
--- a/flang/include/flang/Parser/provenance.h
+++ b/flang/include/flang/Parser/provenance.h
@@ -14,7 +14,7 @@
 #include "characters.h"
 #include "source.h"
 #include "flang/Common/idioms.h"
-#include "flang/Common/interval.h"
+#include "flang/Support/interval.h"
 #include "llvm/Support/raw_ostream.h"
 #include <cstddef>
 #include <list>
diff --git a/flang/include/flang/Parser/source.h b/flang/include/flang/Parser/source.h
index a6efdf9546c7f3..a67fd66045a3de 100644
--- a/flang/include/flang/Parser/source.h
+++ b/flang/include/flang/Parser/source.h
@@ -15,7 +15,7 @@
 //  - A Unicode byte order mark is recognized if present.
 
 #include "characters.h"
-#include "flang/Common/reference.h"
+#include "flang/Support/reference.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/raw_ostream.h"
 #include <cstddef>
diff --git a/flang/include/flang/Parser/user-state.h b/flang/include/flang/Parser/user-state.h
index 61745a833c715c..fff651208e0e52 100644
--- a/flang/include/flang/Parser/user-state.h
+++ b/flang/include/flang/Parser/user-state.h
@@ -14,7 +14,7 @@
 // parse tree construction so as to avoid any need for representing
 // state in static data.
 
-#include "flang/Common/Fortran-features.h"
+#include "flang/Support/Fortran-features.h"
 #include "flang/Common/idioms.h"
 #include "flang/Parser/char-block.h"
 #include "flang/Parser/parse-tree.h"
diff --git a/flang/include/flang/Semantics/expression.h b/flang/include/flang/Semantics/expression.h
index c90c8c4b3cc70f..77e26ffb834dd9 100644
--- a/flang/include/flang/Semantics/expression.h
+++ b/flang/include/flang/Semantics/expression.h
@@ -10,8 +10,8 @@
 #define FORTRAN_SEMANTICS_EXPRESSION_H_
 
 #include "semantics.h"
-#include "flang/Common/Fortran.h"
-#include "flang/Common/indirection.h"
+#include "flang/Support/Fortran.h"
+#include "flang/Support/indirection.h"
 #include "flang/Common/restorer.h"
 #include "flang/Common/visit.h"
 #include "flang/Evaluate/characteristics.h"
diff --git a/flang/include/flang/Semantics/runtime-type-info.h b/flang/include/flang/Semantics/runtime-type-info.h
index e90d3ae8baf1eb..3f9f776797d782 100644
--- a/flang/include/flang/Semantics/runtime-type-info.h
+++ b/flang/include/flang/Semantics/runtime-type-info.h
@@ -14,7 +14,7 @@
 #ifndef FORTRAN_SEMANTICS_RUNTIME_TYPE_INFO_H_
 #define FORTRAN_SEMANTICS_RUNTIME_TYPE_INFO_H_
 
-#include "flang/Common/reference.h"
+#include "flang/Support/reference.h"
 #include "flang/Semantics/symbol.h"
 #include <map>
 #include <set>
diff --git a/flang/include/flang/Semantics/scope.h b/flang/include/flang/Semantics/scope.h
index e73a507e9b3f5b..8b416dcffb5245 100644
--- a/flang/include/flang/Semantics/scope.h
+++ b/flang/include/flang/Semantics/scope.h
@@ -11,9 +11,9 @@
 
 #include "attr.h"
 #include "symbol.h"
-#include "flang/Common/Fortran.h"
+#include "flang/Support/Fortran.h"
 #include "flang/Common/idioms.h"
-#include "flang/Common/reference.h"
+#include "flang/Support/reference.h"
 #include "flang/Parser/message.h"
 #include "flang/Parser/provenance.h"
 #include <list>
diff --git a/flang/include/flang/Semantics/semantics.h b/flang/include/flang/Semantics/semantics.h
index e73f9d2e85d589..899d4afa016bff 100644
--- a/flang/include/flang/Semantics/semantics.h
+++ b/flang/include/flang/Semantics/semantics.h
@@ -11,7 +11,7 @@
 
 #include "scope.h"
 #include "symbol.h"
-#include "flang/Common/Fortran-features.h"
+#include "flang/Support/Fortran-features.h"
 #include "flang/Evaluate/common.h"
 #include "flang/Evaluate/intrinsics.h"
 #include "flang/Evaluate/target.h"
diff --git a/flang/include/flang/Semantics/symbol.h b/flang/include/flang/Semantics/symbol.h
index b4db6689a94271..29587be2c7d77d 100644
--- a/flang/include/flang/Semantics/symbol.h
+++ b/flang/include/flang/Semantics/symbol.h
@@ -10,9 +10,9 @@
 #define FORTRAN_SEMANTICS_SYMBOL_H_
 
 #include "type.h"
-#include "flang/Common/Fortran.h"
+#include "flang/Support/Fortran.h"
 #include "flang/Common/enum-set.h"
-#include "flang/Common/reference.h"
+#include "flang/Support/reference.h"
 #include "flang/Common/visit.h"
 #include "flang/Semantics/module-dependences.h"
 #include "llvm/ADT/DenseMapInfo.h"
diff --git a/flang/include/flang/Semantics/tools.h b/flang/include/flang/Semantics/tools.h
index 15c02ecc0058cc..9be7ebff9b5bb6 100644
--- a/flang/include/flang/Semantics/tools.h
+++ b/flang/include/flang/Semantics/tools.h
@@ -12,7 +12,7 @@
 // Simple predicates and look-up functions that are best defined
 // canonically for use in semantic checking.
 
-#include "flang/Common/Fortran.h"
+#include "flang/Support/Fortran.h"
 #include "flang/Common/visit.h"
 #include "flang/Evaluate/expression.h"
 #include "flang/Evaluate/shape.h"
diff --git a/flang/include/flang/Semantics/type.h b/flang/include/flang/Semantics/type.h
index e2d47d38f927f7..fd31bc805e2de6 100644
--- a/flang/include/flang/Semantics/type.h
+++ b/flang/include/flang/Semantics/type.h
@@ -9,7 +9,7 @@
 #ifndef FORTRAN_SEMANTICS_TYPE_H_
 #define FORTRAN_SEMANTICS_TYPE_H_
 
-#include "flang/Common/Fortran.h"
+#include "flang/Support/Fortran.h"
 #include "flang/Common/idioms.h"
 #include "flang/Evaluate/expression.h"
 #include "flang/Parser/char-block.h"
diff --git a/flang/include/flang/Common/Fortran-features.h b/flang/include/flang/Support/Fortran-features.h
similarity index 98%
rename from flang/include/flang/Common/Fortran-features.h
rename to flang/include/flang/Support/Fortran-features.h
index 86c6e02b0f2ffd..f0bfc9232ea9e9 100644
--- a/flang/include/flang/Common/Fortran-features.h
+++ b/flang/include/flang/Support/Fortran-features.h
@@ -1,4 +1,4 @@
-//===-- include/flang/Common/Fortran-features.h -----------------*- C++ -*-===//
+//===-- include/flang/Support/Fortran-features.h ----------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -9,7 +9,7 @@
 #ifndef FORTRAN_COMMON_FORTRAN_FEATURES_H_
 #define FORTRAN_COMMON_FORTRAN_FEATURES_H_
 
-#include "flang/Common/Fortran.h"
+#include "flang/Support/Fortran.h"
 #include "flang/Common/enum-set.h"
 #include "flang/Common/idioms.h"
 #include <vector>
diff --git a/flang/include/flang/Common/Fortran.h b/flang/include/flang/Support/Fortran.h
similarity index 73%
rename from flang/include/flang/Common/Fortran.h
rename to flang/include/flang/Support/Fortran.h
index 5b2ed43a8f99c0..6dbfb51f19dd8e 100644
--- a/flang/include/flang/Common/Fortran.h
+++ b/flang/include/flang/Support/Fortran.h
@@ -1,4 +1,4 @@
-//===-- include/flang/Common/Fortran.h --------------------------*- C++ -*-===//
+//===-- include/flang/Support/Fortran.h -------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -9,21 +9,20 @@
 #ifndef FORTRAN_COMMON_FORTRAN_H_
 #define FORTRAN_COMMON_FORTRAN_H_
 
-// Fortran language concepts that are used in many phases are defined
-// once here to avoid redundancy and needless translation.
 
-#include "enum-set.h"
-#include "idioms.h"
+
+#include "flang/Common/Fortran-consts.h"
+#include "flang/Common/enum-set.h"
+#include "flang/Common/idioms.h"
 #include <cinttypes>
 #include <optional>
 #include <string>
 
+
 namespace Fortran::common {
-class LanguageFeatureControl;
+	class LanguageFeatureControl;
+
 
-// Fortran has five kinds of intrinsic data types, plus the derived types.
-ENUM_CLASS(TypeCategory, Integer, Real, Complex, Character, Logical, Derived)
-ENUM_CLASS(VectorElementCategory, Integer, Unsigned, Real)
 
 constexpr bool IsNumericTypeCategory(TypeCategory category) {
   return category == TypeCategory::Integer || category == TypeCategory::Real ||
@@ -47,8 +46,6 @@ const char *AsFortran(RelationalOperator);
 
 ENUM_CLASS(Intent, Default, In, Out, InOut)
 
-ENUM_CLASS(IoStmtKind, None, Backspace, Close, Endfile, Flush, Inquire, Open,
-    Print, Read, Rewind, Wait, Write)
 
 // Union of specifiers for all I/O statements.
 ENUM_CLASS(IoSpecKind, Access, Action, Advance, Asynchronous, Blank, Decimal,
@@ -61,28 +58,14 @@ ENUM_CLASS(IoSpecKind, Access, Action, Advance, Asynchronous, Blank, Decimal,
     Dispose, // nonstandard
 )
 
-// Defined I/O variants
-ENUM_CLASS(
-    DefinedIo, ReadFormatted, ReadUnformatted, WriteFormatted, WriteUnformatted)
+
 const char *AsFortran(DefinedIo);
 
-// Floating-point rounding modes; these are packed into a byte to save
-// room in the runtime's format processing context structure.  These
-// enumerators are defined with the corresponding values returned from
-// llvm.get.rounding.
-enum class RoundingMode : std::uint8_t {
-  ToZero, // ROUND=ZERO, RZ - truncation
-  TiesToEven, // ROUND=NEAREST, RN - default IEEE rounding
-  Up, // ROUND=UP, RU
-  Down, // ROUND=DOWN, RD
-  TiesAwayFromZero, // ROUND=COMPATIBLE, RC - ties round away from zero
-};
 
 // Fortran label. Must be in [1..99999].
 using Label = std::uint64_t;
 
-// Fortran arrays may have up to 15 dimensions (See Fortran 2018 section 5.4.6).
-static constexpr int maxRank{15};
+
 
 // CUDA subprogram attribute combinations
 ENUM_CLASS(CUDASubprogramAttrs, Host, Device, HostDevice, Global, Grid_Global)
@@ -129,6 +112,5 @@ inline std::string GetExternalAssemblyName(
     std::string symbolName, bool underscoring) {
   return underscoring ? std::move(symbolName) + "_" : std::move(symbolName);
 }
-
 } // namespace Fortran::common
 #endif // FORTRAN_COMMON_FORTRAN_H_
diff --git a/flang/include/flang/Common/MathOptionsBase.def b/flang/include/flang/Support/MathOptionsBase.def
similarity index 100%
rename from flang/include/flang/Common/MathOptionsBase.def
rename to flang/include/flang/Support/MathOptionsBase.def
diff --git a/flang/include/flang/Common/MathOptionsBase.h b/flang/include/flang/Support/MathOptionsBase.h
similarity index 86%
rename from flang/include/flang/Common/MathOptionsBase.h
rename to flang/include/flang/Support/MathOptionsBase.h
index 7f8ebdbee19878..a739ba3e066599 100644
--- a/flang/include/flang/Common/MathOptionsBase.h
+++ b/flang/include/flang/Support/MathOptionsBase.h
@@ -1,4 +1,4 @@
-//===- MathOptionsBase.h - Math options config ------------------*- C++ -*-===//
+//===-- include/flang/Support/MathOptionsBase.h -----------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -27,16 +27,16 @@ class MathOptionsBase {
     Name = static_cast<unsigned>(Value); \
     return *this; \
   }
-#include "flang/Common/MathOptionsBase.def"
+#include "flang/Support/MathOptionsBase.def"
 
   MathOptionsBase() {
 #define ENUM_MATHOPT(Name, Type, Bits, Default) set##Name(Default);
-#include "flang/Common/MathOptionsBase.def"
+#include "flang/Support/MathOptionsBase.def"
   }
 
 private:
 #define ENUM_MATHOPT(Name, Type, Bits, Default) unsigned Name : Bits;
-#include "flang/Common/MathOptionsBase.def"
+#include "flang/Support/MathOptionsBase.def"
 };
 
 } // namespace Fortran::common
diff --git a/flang/include/flang/Common/OpenMP-features.h b/flang/include/flang/Support/OpenMP-features.h
similarity index 94%
rename from flang/include/flang/Common/OpenMP-features.h
rename to flang/include/flang/Support/OpenMP-features.h
index 480c8b4c1013fe..fb73d4191d1c1a 100644
--- a/flang/include/flang/Common/OpenMP-features.h
+++ b/flang/include/flang/Support/OpenMP-features.h
@@ -1,4 +1,4 @@
-//===-- include/flang/Common/OpenMP-features.h -----------------*- C++ -*-====//
+//===-- include/flang/Support/OpenMP-features.h -----------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/include/flang/Common/Version.h b/flang/include/flang/Support/Version.h
similarity index 95%
rename from flang/include/flang/Common/Version.h
rename to flang/include/flang/Support/Version.h
index 3257d4a4f64593..643ddd2e27f69a 100644
--- a/flang/include/flang/Common/Version.h
+++ b/flang/include/flang/Support/Version.h
@@ -1,4 +1,4 @@
-//===- Version.h - Flang Version Number ---------------------*- Fortran -*-===//
+//===-- include/flang/Support/Version.h -------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/include/flang/Common/default-kinds.h b/flang/include/flang/Support/default-kinds.h
similarity index 96%
rename from flang/include/flang/Common/default-kinds.h
rename to flang/include/flang/Support/default-kinds.h
index 6c66b98e98a05b..e78a08dfae6cc3 100644
--- a/flang/include/flang/Common/default-kinds.h
+++ b/flang/include/flang/Support/default-kinds.h
@@ -1,4 +1,4 @@
-//===-- include/flang/Common/default-kinds.h --------------------*- C++ -*-===//
+//===-- include/flang/Support/default-kinds.h -------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -9,7 +9,7 @@
 #ifndef FORTRAN_COMMON_DEFAULT_KINDS_H_
 #define FORTRAN_COMMON_DEFAULT_KINDS_H_
 
-#include "flang/Common/Fortran.h"
+#include "flang/Support/Fortran.h"
 #include <cstdint>
 
 namespace Fortran::common {
diff --git a/flang/include/flang/Common/indirection.h b/flang/include/flang/Support/indirection.h
similarity index 98%
rename from flang/include/flang/Common/indirection.h
rename to flang/include/flang/Support/indirection.h
index 7348eb0473f072..1221a659323503 100644
--- a/flang/include/flang/Common/indirection.h
+++ b/flang/include/flang/Support/indirection.h
@@ -1,4 +1,4 @@
-//===-- include/flang/Common/indirection.h ----------------------*- C++ -*-===//
+//===-- include/flang/Support/indirection.h ---------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -20,7 +20,7 @@
 //    template class Fortran::common::Indirection<FORWARD_TYPE>;
 // in one C++ source file later where a definition of the type is visible.
 
-#include "idioms.h"
+#include "flang/Common/idioms.h"
 #include <memory>
 #include <type_traits>
 #include <utility>
diff --git a/flang/include/flang/Common/interval.h b/flang/include/flang/Support/interval.h
similarity index 97%
rename from flang/include/flang/Common/interval.h
rename to flang/include/flang/Support/interval.h
index c4cab0ccf1130b..2918cc54de3926 100644
--- a/flang/include/flang/Common/interval.h
+++ b/flang/include/flang/Support/interval.h
@@ -1,4 +1,4 @@
-//===-- include/flang/Common/interval.h -------------------------*- C++ -*-===//
+//===-- include/flang/Support/interval.h ------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -12,7 +12,7 @@
 // Defines a generalized template class Interval<A> to represent
 // the half-open interval [x .. x+n).
 
-#include "idioms.h"
+#include "flang/Common/idioms.h"
 #include <algorithm>
 #include <cstddef>
 #include <utility>
diff --git a/flang/include/flang/Common/reference-counted.h b/flang/include/flang/Support/reference-counted.h
similarity index 96%
rename from flang/include/flang/Common/reference-counted.h
rename to flang/include/flang/Support/reference-counted.h
index de91d4fb6ee8b7..d7a065c59d5a0f 100644
--- a/flang/include/flang/Common/reference-counted.h
+++ b/flang/include/flang/Support/reference-counted.h
@@ -1,4 +1,4 @@
-//===-- include/flang/Common/reference-counted.h ----------------*- C++ -*-===//
+//===-- include/flang/Support/reference-counted.h ---------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/include/flang/Common/reference.h b/flang/include/flang/Support/reference.h
similarity index 97%
rename from flang/include/flang/Common/reference.h
rename to flang/include/flang/Support/reference.h
index 0c579de44bd7fa..cb367ae231376d 100644
--- a/flang/include/flang/Common/reference.h
+++ b/flang/include/flang/Support/reference.h
@@ -1,4 +1,4 @@
-//===-- include/flang/Common/reference.h ------------------------*- C++ -*-===//
+//===-- include/flang/Support/reference.h -----------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/include/flang/Common/static-multimap-view.h b/flang/include/flang/Support/static-multimap-view.h
similarity index 97%
rename from flang/include/flang/Common/static-multimap-view.h
rename to flang/include/flang/Support/static-multimap-view.h
index 27d2ba89c8009c..71da272a26de2f 100644
--- a/flang/include/flang/Common/static-multimap-view.h
+++ b/flang/include/flang/Support/static-multimap-view.h
@@ -1,4 +1,4 @@
-//===-- include/flang/Common/static-multimap-view.h -------------*- C++ -*-===//
+//===-- include/flang/Support/static-multimap-view.h ------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/include/flang/Common/template.h b/flang/include/flang/Support/template.h
similarity index 99%
rename from flang/include/flang/Common/template.h
rename to flang/include/flang/Support/template.h
index 51d09fb42ce368..e15de9c2d0cea8 100644
--- a/flang/include/flang/Common/template.h
+++ b/flang/include/flang/Support/template.h
@@ -1,4 +1,4 @@
-//===-- include/flang/Common/template.h -------------------------*- C++ -*-===//
+//===-- include/flang/Support/template.h ------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -9,7 +9,7 @@
 #ifndef FORTRAN_COMMON_TEMPLATE_H_
 #define FORTRAN_COMMON_TEMPLATE_H_
 
-#include "variant.h"
+#include "flang/Common/variant.h"
 #include "flang/Common/idioms.h"
 #include <functional>
 #include <optional>
diff --git a/flang/include/flang/Common/unwrap.h b/flang/include/flang/Support/unwrap.h
similarity index 97%
rename from flang/include/flang/Common/unwrap.h
rename to flang/include/flang/Support/unwrap.h
index 84582174e4b300..d8fa553dedda3f 100644
--- a/flang/include/flang/Common/unwrap.h
+++ b/flang/include/flang/Support/unwrap.h
@@ -1,4 +1,4 @@
-//===-- include/flang/Common/unwrap.h ---------------------------*- C++ -*-===//
+//===-- include/flang/Support/unwrap.h --------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -12,8 +12,8 @@
 #include "indirection.h"
 #include "reference-counted.h"
 #include "reference.h"
-#include "variant.h"
-#include "visit.h"
+#include "flang/Common/variant.h"
+#include "flang/Common/visit.h"
 #include <memory>
 #include <optional>
 #include <type_traits>
diff --git a/flang/include/flang/Tools/CrossToolHelpers.h b/flang/include/flang/Tools/CrossToolHelpers.h
index 75fd783af237d0..bc105f471aa003 100644
--- a/flang/include/flang/Tools/CrossToolHelpers.h
+++ b/flang/include/flang/Tools/CrossToolHelpers.h
@@ -13,7 +13,7 @@
 #ifndef FORTRAN_TOOLS_CROSS_TOOL_HELPERS_H
 #define FORTRAN_TOOLS_CROSS_TOOL_HELPERS_H
 
-#include "flang/Common/MathOptionsBase.h"
+#include "flang/Support/MathOptionsBase.h"
 #include "flang/Frontend/CodeGenOptions.h"
 #include "flang/Frontend/LangOptions.h"
 #include <cstdint>
diff --git a/flang/lib/CMakeLists.txt b/flang/lib/CMakeLists.txt
index f41d4df1f07e3c..d29da136ea3eda 100644
--- a/flang/lib/CMakeLists.txt
+++ b/flang/lib/CMakeLists.txt
@@ -1,6 +1,9 @@
+
+include_directories("${CMAKE_CURRENT_SOURCE_DIR}/../../FortranRuntime/include")
+
 add_subdirectory(Common)
+add_subdirectory(Support)
 add_subdirectory(Evaluate)
-add_subdirectory(Decimal)
 add_subdirectory(Lower)
 add_subdirectory(Parser)
 add_subdirectory(Semantics)
diff --git a/flang/lib/Common/CMakeLists.txt b/flang/lib/Common/CMakeLists.txt
index c6f818ad27cd19..b62aeb2c08b779 100644
--- a/flang/lib/Common/CMakeLists.txt
+++ b/flang/lib/Common/CMakeLists.txt
@@ -1,48 +1,12 @@
-find_first_existing_vc_file("${LLVM_MAIN_SRC_DIR}" llvm_vc)
-find_first_existing_vc_file("${FLANG_SOURCE_DIR}" flang_vc)
-
-# The VC revision include that we want to generate.
-set(version_inc "${CMAKE_CURRENT_BINARY_DIR}/VCSVersion.inc")
-
-set(generate_vcs_version_script "${LLVM_CMAKE_DIR}/GenerateVersionFromVCS.cmake")
-
-if(llvm_vc AND LLVM_APPEND_VC_REV)
-  set(llvm_source_dir ${LLVM_MAIN_SRC_DIR})
-endif()
-if(flang_vc AND LLVM_APPEND_VC_REV)
-  set(flang_source_dir ${FLANG_SOURCE_DIR})
-endif()
- 
-# Create custom target to generate the VC revision include.
-add_custom_command(OUTPUT "${version_inc}"
-  DEPENDS "${llvm_vc}" "${flang_vc}" "${generate_vcs_version_script}"
-  COMMAND ${CMAKE_COMMAND} "-DNAMES=\"LLVM;FLANG\""
-                           "-DLLVM_SOURCE_DIR=${llvm_source_dir}"
-                           "-DFLANG_SOURCE_DIR=${flang_source_dir}"
-                           "-DHEADER_FILE=${version_inc}"
-                           "-DLLVM_FORCE_VC_REVISION=${LLVM_FORCE_VC_REVISION}"
-                           "-DLLVM_FORCE_VC_REPOSITORY=${LLVM_FORCE_VC_REPOSITORY}"
-                           -P "${generate_vcs_version_script}")
-
-# Mark the generated header as being generated.
-set_source_files_properties("${version_inc}"
-  PROPERTIES GENERATED TRUE
-             HEADER_FILE_ONLY TRUE)
-
-if(FLANG_VENDOR)
-  set_source_files_properties(Version.cpp
-    PROPERTIES COMPILE_DEFINITIONS "FLANG_VENDOR=\"${FLANG_VENDOR} \"")
-endif()
-
-
-add_flang_library(FortranCommon
-  Fortran.cpp
-  Fortran-features.cpp
-  default-kinds.cpp
-  idioms.cpp
-  Version.cpp
-  ${version_inc}
-
-  LINK_COMPONENTS
-  Support
-)
+#===-- FortranRuntime/lib/Common/CMakeLists.txt ---------------------------===#
+#
+# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+# See https://llvm.org/LICENSE.txt for license information.
+# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+#
+#===------------------------------------------------------------------------===#
+
+add_flang_library(FortranCommon 
+  "${CMAKE_CURRENT_SOURCE_DIR}/../../../FortranRuntime/lib/Common/binary-to-decimal.cpp"
+  "${CMAKE_CURRENT_SOURCE_DIR}/../../../FortranRuntime/lib/Common/decimal-to-binary.cpp"
+)
diff --git a/flang/lib/Decimal/CMakeLists.txt b/flang/lib/Decimal/CMakeLists.txt
deleted file mode 100644
index 880b190f1c5815..00000000000000
--- a/flang/lib/Decimal/CMakeLists.txt
+++ /dev/null
@@ -1,86 +0,0 @@
-if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
-  cmake_minimum_required(VERSION 3.20.0)
-
-  project(FortranDecimal C CXX)
-
-  set(CMAKE_CXX_STANDARD 17)
-  set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
-  set(CMAKE_CXX_EXTENSIONS OFF)
-
-  set(FLANG_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../..")
-
-  set(LLVM_COMMON_CMAKE_UTILS "${FLANG_SOURCE_DIR}/../cmake")
-  set(LLVM_CMAKE_UTILS "${FLANG_SOURCE_DIR}/../llvm/cmake")
-  set(CLANG_CMAKE_UTILS "${FLANG_SOURCE_DIR}/../clang/cmake")
-
-  # Add path for custom modules
-  list(INSERT CMAKE_MODULE_PATH 0
-    "${FLANG_SOURCE_DIR}/cmake"
-    "${FLANG_SOURCE_DIR}/cmake/modules"
-    "${LLVM_COMMON_CMAKE_UTILS}"
-    "${LLVM_COMMON_CMAKE_UTILS}/Modules"
-    "${LLVM_CMAKE_UTILS}"
-    "${LLVM_CMAKE_UTILS}/modules"
-    "${CLANG_CMAKE_UTILS}/modules"
-    )
-
-  include(AddClang)
-  include(AddLLVM)
-  include(AddFlang)
-  include(HandleLLVMOptions)
-
-  include(TestBigEndian)
-  test_big_endian(IS_BIGENDIAN)
-  if (IS_BIGENDIAN)
-    add_compile_definitions(FLANG_BIG_ENDIAN=1)
-  else ()
-    add_compile_definitions(FLANG_LITTLE_ENDIAN=1)
-  endif ()
-  include_directories(BEFORE
-    ${FLANG_SOURCE_DIR}/include)
-endif()
-
-check_cxx_compiler_flag(-fno-lto FLANG_RUNTIME_HAS_FNO_LTO_FLAG)
-if (FLANG_RUNTIME_HAS_FNO_LTO_FLAG)
-  append("-fno-lto" CMAKE_CXX_FLAGS)
-endif()
-
-# Disable libstdc++ assertions, even in an LLVM_ENABLE_ASSERTIONS build, to
-# avoid an unwanted dependency on libstdc++.so.
-add_definitions(-U_GLIBCXX_ASSERTIONS)
-
-set(sources
-  binary-to-decimal.cpp
-  decimal-to-binary.cpp
-)
-
-include(AddFlangOffloadRuntime)
-enable_cuda_compilation(FortranDecimal "${sources}")
-enable_omp_offload_compilation("${sources}")
-
-add_flang_library(FortranDecimal INSTALL_WITH_TOOLCHAIN ${sources})
-
-if (DEFINED MSVC)
-  set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreaded)
-  add_flang_library(FortranDecimal.static INSTALL_WITH_TOOLCHAIN
-          binary-to-decimal.cpp
-          decimal-to-binary.cpp
-  )
-  set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreadedDLL)
-  add_flang_library(FortranDecimal.dynamic INSTALL_WITH_TOOLCHAIN
-    binary-to-decimal.cpp
-    decimal-to-binary.cpp
-  )
-  set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreadedDebug)
-  add_flang_library(FortranDecimal.static_dbg INSTALL_WITH_TOOLCHAIN
-          binary-to-decimal.cpp
-          decimal-to-binary.cpp
-  )
-  set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreadedDebugDLL)
-  add_flang_library(FortranDecimal.dynamic_dbg INSTALL_WITH_TOOLCHAIN
-    binary-to-decimal.cpp
-    decimal-to-binary.cpp
-  )
-  add_dependencies(FortranDecimal FortranDecimal.static FortranDecimal.dynamic
-    FortranDecimal.static_dbg FortranDecimal.dynamic_dbg)
-endif()
diff --git a/flang/lib/Evaluate/CMakeLists.txt b/flang/lib/Evaluate/CMakeLists.txt
index b38f450d746ea7..5f2e345b7bfb56 100644
--- a/flang/lib/Evaluate/CMakeLists.txt
+++ b/flang/lib/Evaluate/CMakeLists.txt
@@ -60,9 +60,8 @@ add_flang_library(FortranEvaluate
   variable.cpp
 
   LINK_LIBS
-  FortranCommon
-  FortranDecimal
   FortranParser
+  FortranSupport
   ${LIBPGMATH}
   ${QUADMATHLIB}
 
diff --git a/flang/lib/Evaluate/call.cpp b/flang/lib/Evaluate/call.cpp
index c5b50e806d2497..1cb8eb89f41687 100644
--- a/flang/lib/Evaluate/call.cpp
+++ b/flang/lib/Evaluate/call.cpp
@@ -7,7 +7,7 @@
 //===----------------------------------------------------------------------===//
 
 #include "flang/Evaluate/call.h"
-#include "flang/Common/Fortran.h"
+#include "flang/Support/Fortran.h"
 #include "flang/Common/idioms.h"
 #include "flang/Evaluate/characteristics.h"
 #include "flang/Evaluate/check-expression.h"
diff --git a/flang/lib/Evaluate/characteristics.cpp b/flang/lib/Evaluate/characteristics.cpp
index 70e24d6e82eb8e..091f2e2b553e86 100644
--- a/flang/lib/Evaluate/characteristics.cpp
+++ b/flang/lib/Evaluate/characteristics.cpp
@@ -7,7 +7,7 @@
 //===----------------------------------------------------------------------===//
 
 #include "flang/Evaluate/characteristics.h"
-#include "flang/Common/indirection.h"
+#include "flang/Support/indirection.h"
 #include "flang/Evaluate/check-expression.h"
 #include "flang/Evaluate/fold.h"
 #include "flang/Evaluate/intrinsics.h"
diff --git a/flang/lib/Evaluate/common.cpp b/flang/lib/Evaluate/common.cpp
index c633bff57b1ecd..7741bec650575d 100644
--- a/flang/lib/Evaluate/common.cpp
+++ b/flang/lib/Evaluate/common.cpp
@@ -9,10 +9,14 @@
 #include "flang/Evaluate/common.h"
 #include "flang/Common/idioms.h"
 
+
 using namespace Fortran::parser::literals;
 
+
+
 namespace Fortran::evaluate {
 
+
 void RealFlagWarnings(
     FoldingContext &context, const RealFlags &flags, const char *operation) {
   if (context.languageFeatures().ShouldWarn(
diff --git a/flang/lib/Evaluate/fold-implementation.h b/flang/lib/Evaluate/fold-implementation.h
index 1b14a305b87f4f..c8452cdd6a0caa 100644
--- a/flang/lib/Evaluate/fold-implementation.h
+++ b/flang/lib/Evaluate/fold-implementation.h
@@ -12,9 +12,9 @@
 #include "character.h"
 #include "host.h"
 #include "int-power.h"
-#include "flang/Common/indirection.h"
-#include "flang/Common/template.h"
-#include "flang/Common/unwrap.h"
+#include "flang/Support/indirection.h"
+#include "flang/Support/template.h"
+#include "flang/Support/unwrap.h"
 #include "flang/Evaluate/characteristics.h"
 #include "flang/Evaluate/common.h"
 #include "flang/Evaluate/constant.h"
diff --git a/flang/lib/Evaluate/formatting.cpp b/flang/lib/Evaluate/formatting.cpp
index 0870d56549f74d..db5d005d97c8c9 100644
--- a/flang/lib/Evaluate/formatting.cpp
+++ b/flang/lib/Evaluate/formatting.cpp
@@ -7,7 +7,7 @@
 //===----------------------------------------------------------------------===//
 
 #include "flang/Evaluate/formatting.h"
-#include "flang/Common/Fortran.h"
+#include "flang/Support/Fortran.h"
 #include "flang/Evaluate/call.h"
 #include "flang/Evaluate/constant.h"
 #include "flang/Evaluate/expression.h"
diff --git a/flang/lib/Evaluate/intrinsics-library.cpp b/flang/lib/Evaluate/intrinsics-library.cpp
index ed28d8130808fa..440ddaaf9689c8 100644
--- a/flang/lib/Evaluate/intrinsics-library.cpp
+++ b/flang/lib/Evaluate/intrinsics-library.cpp
@@ -14,7 +14,7 @@
 #include "flang/Evaluate/intrinsics-library.h"
 #include "fold-implementation.h"
 #include "host.h"
-#include "flang/Common/static-multimap-view.h"
+#include "flang/Support/static-multimap-view.h"
 #include "flang/Evaluate/expression.h"
 #include <cfloat>
 #include <cmath>
diff --git a/flang/lib/Evaluate/intrinsics.cpp b/flang/lib/Evaluate/intrinsics.cpp
index 166dae93178c51..343bd2c9f22be2 100644
--- a/flang/lib/Evaluate/intrinsics.cpp
+++ b/flang/lib/Evaluate/intrinsics.cpp
@@ -7,7 +7,7 @@
 //===----------------------------------------------------------------------===//
 
 #include "flang/Evaluate/intrinsics.h"
-#include "flang/Common/Fortran.h"
+#include "flang/Support/Fortran.h"
 #include "flang/Common/enum-set.h"
 #include "flang/Common/idioms.h"
 #include "flang/Evaluate/check-expression.h"
diff --git a/flang/lib/Evaluate/real.cpp b/flang/lib/Evaluate/real.cpp
index 642490646dcaf3..9d465e5f35d6ae 100644
--- a/flang/lib/Evaluate/real.cpp
+++ b/flang/lib/Evaluate/real.cpp
@@ -9,7 +9,7 @@
 #include "flang/Evaluate/real.h"
 #include "int-power.h"
 #include "flang/Common/idioms.h"
-#include "flang/Decimal/decimal.h"
+#include "flang/Common/decimal.h"
 #include "flang/Parser/characters.h"
 #include "llvm/Support/raw_ostream.h"
 #include <limits>
diff --git a/flang/lib/Evaluate/shape.cpp b/flang/lib/Evaluate/shape.cpp
index c62d0cb0ff29dd..7b78d8c7b9734f 100644
--- a/flang/lib/Evaluate/shape.cpp
+++ b/flang/lib/Evaluate/shape.cpp
@@ -8,7 +8,7 @@
 
 #include "flang/Evaluate/shape.h"
 #include "flang/Common/idioms.h"
-#include "flang/Common/template.h"
+#include "flang/Support/template.h"
 #include "flang/Evaluate/characteristics.h"
 #include "flang/Evaluate/check-expression.h"
 #include "flang/Evaluate/fold.h"
diff --git a/flang/lib/Evaluate/target.cpp b/flang/lib/Evaluate/target.cpp
index 1e2cf6b0d298d4..d0722c31e3c3f7 100644
--- a/flang/lib/Evaluate/target.cpp
+++ b/flang/lib/Evaluate/target.cpp
@@ -7,7 +7,7 @@
 //===----------------------------------------------------------------------===//
 
 #include "flang/Evaluate/target.h"
-#include "flang/Common/template.h"
+#include "flang/Support/template.h"
 #include "flang/Evaluate/common.h"
 #include "flang/Evaluate/type.h"
 
diff --git a/flang/lib/Frontend/CMakeLists.txt b/flang/lib/Frontend/CMakeLists.txt
index ecdcc73d61ec1f..9b20b6a92cca0f 100644
--- a/flang/lib/Frontend/CMakeLists.txt
+++ b/flang/lib/Frontend/CMakeLists.txt
@@ -28,7 +28,7 @@ add_flang_library(flangFrontend
   FortranParser
   FortranSemantics
   FortranEvaluate
-  FortranCommon
+  FortranSupport
   FortranLower
   FIRDialect
   FIRDialectSupport
diff --git a/flang/lib/Frontend/CompilerInstance.cpp b/flang/lib/Frontend/CompilerInstance.cpp
index d37430e0e5773e..a0653576852101 100644
--- a/flang/lib/Frontend/CompilerInstance.cpp
+++ b/flang/lib/Frontend/CompilerInstance.cpp
@@ -11,7 +11,7 @@
 //===----------------------------------------------------------------------===//
 
 #include "flang/Frontend/CompilerInstance.h"
-#include "flang/Common/Fortran-features.h"
+#include "flang/Support/Fortran-features.h"
 #include "flang/Frontend/CompilerInvocation.h"
 #include "flang/Frontend/TextDiagnosticPrinter.h"
 #include "flang/Parser/parsing.h"
diff --git a/flang/lib/Frontend/CompilerInvocation.cpp b/flang/lib/Frontend/CompilerInvocation.cpp
index 90c327546198b5..5fe6ccbc44a894 100644
--- a/flang/lib/Frontend/CompilerInvocation.cpp
+++ b/flang/lib/Frontend/CompilerInvocation.cpp
@@ -11,9 +11,9 @@
 //===----------------------------------------------------------------------===//
 
 #include "flang/Frontend/CompilerInvocation.h"
-#include "flang/Common/Fortran-features.h"
-#include "flang/Common/OpenMP-features.h"
-#include "flang/Common/Version.h"
+#include "flang/Support/Fortran-features.h"
+#include "flang/Support/OpenMP-features.h"
+#include "flang/Support/Version.h"
 #include "flang/Frontend/CodeGenOptions.h"
 #include "flang/Frontend/PreprocessorOptions.h"
 #include "flang/Frontend/TargetOptions.h"
diff --git a/flang/lib/Frontend/FrontendActions.cpp b/flang/lib/Frontend/FrontendActions.cpp
index cda82bcb7ecc71..7d51c20514387a 100644
--- a/flang/lib/Frontend/FrontendActions.cpp
+++ b/flang/lib/Frontend/FrontendActions.cpp
@@ -11,7 +11,7 @@
 //===----------------------------------------------------------------------===//
 
 #include "flang/Frontend/FrontendActions.h"
-#include "flang/Common/default-kinds.h"
+#include "flang/Support/default-kinds.h"
 #include "flang/Frontend/CompilerInstance.h"
 #include "flang/Frontend/CompilerInvocation.h"
 #include "flang/Frontend/FrontendOptions.h"
diff --git a/flang/lib/Lower/Bridge.cpp b/flang/lib/Lower/Bridge.cpp
index 79e5a04463e00b..6924717cb467ac 100644
--- a/flang/lib/Lower/Bridge.cpp
+++ b/flang/lib/Lower/Bridge.cpp
@@ -12,7 +12,7 @@
 
 #include "flang/Lower/Bridge.h"
 #include "DirectivesCommon.h"
-#include "flang/Common/Version.h"
+#include "flang/Support/Version.h"
 #include "flang/Lower/Allocatable.h"
 #include "flang/Lower/CallInterface.h"
 #include "flang/Lower/Coarray.h"
diff --git a/flang/lib/Lower/CMakeLists.txt b/flang/lib/Lower/CMakeLists.txt
index ba6622d8504a4f..cb37857ab1de0b 100644
--- a/flang/lib/Lower/CMakeLists.txt
+++ b/flang/lib/Lower/CMakeLists.txt
@@ -56,7 +56,7 @@ add_flang_library(FortranLower
   HLFIRDialect
   ${dialect_libs}
   ${extension_libs}
-  FortranCommon
+  FortranSupport
   FortranParser
   FortranEvaluate
   FortranSemantics
diff --git a/flang/lib/Lower/CallInterface.cpp b/flang/lib/Lower/CallInterface.cpp
index c0ef96adc20c3e..153845699dae3d 100644
--- a/flang/lib/Lower/CallInterface.cpp
+++ b/flang/lib/Lower/CallInterface.cpp
@@ -7,7 +7,7 @@
 //===----------------------------------------------------------------------===//
 
 #include "flang/Lower/CallInterface.h"
-#include "flang/Common/Fortran.h"
+#include "flang/Support/Fortran.h"
 #include "flang/Evaluate/fold.h"
 #include "flang/Lower/Bridge.h"
 #include "flang/Lower/Mangler.h"
diff --git a/flang/lib/Lower/ConvertExpr.cpp b/flang/lib/Lower/ConvertExpr.cpp
index 62a7615e1af13c..4d2ac95ea784b5 100644
--- a/flang/lib/Lower/ConvertExpr.cpp
+++ b/flang/lib/Lower/ConvertExpr.cpp
@@ -11,8 +11,8 @@
 //===----------------------------------------------------------------------===//
 
 #include "flang/Lower/ConvertExpr.h"
-#include "flang/Common/default-kinds.h"
-#include "flang/Common/unwrap.h"
+#include "flang/Support/default-kinds.h"
+#include "flang/Support/unwrap.h"
 #include "flang/Evaluate/fold.h"
 #include "flang/Evaluate/real.h"
 #include "flang/Evaluate/traverse.h"
diff --git a/flang/lib/Lower/Mangler.cpp b/flang/lib/Lower/Mangler.cpp
index a66dae8851a866..565f9c6cbc5892 100644
--- a/flang/lib/Lower/Mangler.cpp
+++ b/flang/lib/Lower/Mangler.cpp
@@ -7,7 +7,7 @@
 //===----------------------------------------------------------------------===//
 
 #include "flang/Lower/Mangler.h"
-#include "flang/Common/reference.h"
+#include "flang/Support/reference.h"
 #include "flang/Lower/Support/Utils.h"
 #include "flang/Optimizer/Builder/Todo.h"
 #include "flang/Optimizer/Dialect/FIRType.h"
diff --git a/flang/lib/Optimizer/Builder/IntrinsicCall.cpp b/flang/lib/Optimizer/Builder/IntrinsicCall.cpp
index dc0dc47bda9a9d..5f1a25b1af23e9 100644
--- a/flang/lib/Optimizer/Builder/IntrinsicCall.cpp
+++ b/flang/lib/Optimizer/Builder/IntrinsicCall.cpp
@@ -14,7 +14,7 @@
 //===----------------------------------------------------------------------===//
 
 #include "flang/Optimizer/Builder/IntrinsicCall.h"
-#include "flang/Common/static-multimap-view.h"
+#include "flang/Support/static-multimap-view.h"
 #include "flang/Optimizer/Builder/BoxValue.h"
 #include "flang/Optimizer/Builder/Character.h"
 #include "flang/Optimizer/Builder/Complex.h"
@@ -68,6 +68,11 @@
 /// a call is generated for it. LLVM intrinsics are handled as a math
 /// runtime library here.
 
+static llvm::cl::opt<bool> ignoreModuleOnlyBuiltins(
+    "ignore-module-only-builtins",
+    llvm::cl::desc("ignore failures from __builtin_numeric_storage_size when compiling FortranRuntime"),
+    llvm::cl::init(false), llvm::cl::Hidden);
+
 namespace fir {
 
 fir::ExtendedValue getAbsentIntrinsicArgument() { return fir::UnboxedValue{}; }
@@ -502,6 +507,7 @@ static constexpr IntrinsicHandler handlers[]{
      /*isElemental=*/false},
     {"not", &I::genNot},
     {"null", &I::genNull, {{{"mold", asInquired}}}, /*isElemental=*/false},
+        {"numeric_storage_size", &I::genNumericStorageSize},
     {"pack",
      &I::genPack,
      {{{"array", asBox},
@@ -7218,6 +7224,19 @@ IntrinsicLibrary::genVerify(mlir::Type resultType,
   return readAndAddCleanUp(resultMutableBox, resultType, "VERIFY");
 }
 
+
+    fir::ExtendedValue IntrinsicLibrary:: genNumericStorageSize(mlir::Type resultType, llvm::ArrayRef<fir::ExtendedValue> args) {
+      assert(args.empty() );
+     
+      if (!ignoreModuleOnlyBuiltins) {
+   fir::emitFatalError(loc, "__builtin_numeric_storage_size is for internal use only. Use NUMERIC_STORAGE_SIZE from ISO_FORTRAN_ENV module instead.");
+  return {};
+      }
+
+      return builder.createIntegerConstant(loc, resultType  , 32 );
+    }
+
+
 /// Process calls to Minloc, Maxloc intrinsic functions
 template <typename FN, typename FD>
 fir::ExtendedValue
diff --git a/flang/lib/Optimizer/CodeGen/TypeConverter.cpp b/flang/lib/Optimizer/CodeGen/TypeConverter.cpp
index 1043494b6fb48a..c632e42ef72c29 100644
--- a/flang/lib/Optimizer/CodeGen/TypeConverter.cpp
+++ b/flang/lib/Optimizer/CodeGen/TypeConverter.cpp
@@ -13,7 +13,7 @@
 #define DEBUG_TYPE "flang-type-conversion"
 
 #include "flang/Optimizer/CodeGen/TypeConverter.h"
-#include "flang/Common/Fortran.h"
+#include "flang/Support/Fortran.h"
 #include "flang/Optimizer/Builder/Todo.h" // remove when TODO's are done
 #include "flang/Optimizer/CodeGen/DescriptorModel.h"
 #include "flang/Optimizer/CodeGen/TBAABuilder.h"
diff --git a/flang/lib/Optimizer/Dialect/FIRType.cpp b/flang/lib/Optimizer/Dialect/FIRType.cpp
index c1debf28d00332..08d75c46faee4b 100644
--- a/flang/lib/Optimizer/Dialect/FIRType.cpp
+++ b/flang/lib/Optimizer/Dialect/FIRType.cpp
@@ -11,7 +11,7 @@
 //===----------------------------------------------------------------------===//
 
 #include "flang/Optimizer/Dialect/FIRType.h"
-#include "flang/ISO_Fortran_binding_wrapper.h"
+#include "flang/Common/ISO_Fortran_binding_wrapper.h"
 #include "flang/Optimizer/Builder/Todo.h"
 #include "flang/Optimizer/Dialect/FIRDialect.h"
 #include "flang/Optimizer/Dialect/Support/KindMapping.h"
diff --git a/flang/lib/Optimizer/Transforms/AddDebugInfo.cpp b/flang/lib/Optimizer/Transforms/AddDebugInfo.cpp
index 46e70d7ef9180a..f41633629bb3e2 100644
--- a/flang/lib/Optimizer/Transforms/AddDebugInfo.cpp
+++ b/flang/lib/Optimizer/Transforms/AddDebugInfo.cpp
@@ -12,7 +12,7 @@
 //===----------------------------------------------------------------------===//
 
 #include "DebugTypeGenerator.h"
-#include "flang/Common/Version.h"
+#include "flang/Support/Version.h"
 #include "flang/Optimizer/Builder/FIRBuilder.h"
 #include "flang/Optimizer/Builder/Todo.h"
 #include "flang/Optimizer/CodeGen/CGOps.h"
diff --git a/flang/lib/Optimizer/Transforms/AssumedRankOpConversion.cpp b/flang/lib/Optimizer/Transforms/AssumedRankOpConversion.cpp
index 2c9c73e8a5394d..ca6eacfd0e7200 100644
--- a/flang/lib/Optimizer/Transforms/AssumedRankOpConversion.cpp
+++ b/flang/lib/Optimizer/Transforms/AssumedRankOpConversion.cpp
@@ -6,7 +6,7 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "flang/Common/Fortran.h"
+#include "flang/Support/Fortran.h"
 #include "flang/Lower/BuiltinModules.h"
 #include "flang/Optimizer/Builder/FIRBuilder.h"
 #include "flang/Optimizer/Builder/Runtime/Support.h"
diff --git a/flang/lib/Optimizer/Transforms/CMakeLists.txt b/flang/lib/Optimizer/Transforms/CMakeLists.txt
index b32f2ef86fca44..35794300dbc6aa 100644
--- a/flang/lib/Optimizer/Transforms/CMakeLists.txt
+++ b/flang/lib/Optimizer/Transforms/CMakeLists.txt
@@ -44,6 +44,7 @@ add_flang_library(FIRTransforms
   FIRDialectSupport
   FIRSupport
   FortranCommon
+  FortranSupport
   HLFIRDialect
   MLIRAffineUtils
   MLIRFuncDialect
diff --git a/flang/lib/Optimizer/Transforms/CufOpConversion.cpp b/flang/lib/Optimizer/Transforms/CufOpConversion.cpp
index c22c74d3f78af7..d3c44a75e4cffb 100644
--- a/flang/lib/Optimizer/Transforms/CufOpConversion.cpp
+++ b/flang/lib/Optimizer/Transforms/CufOpConversion.cpp
@@ -6,7 +6,7 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "flang/Common/Fortran.h"
+#include "flang/Support/Fortran.h"
 #include "flang/Optimizer/Builder/Runtime/RTBuilder.h"
 #include "flang/Optimizer/CodeGen/TypeConverter.h"
 #include "flang/Optimizer/Dialect/CUF/CUFOps.h"
diff --git a/flang/lib/Optimizer/Transforms/ExternalNameConversion.cpp b/flang/lib/Optimizer/Transforms/ExternalNameConversion.cpp
index 648628fd1c9af0..1915abe2f91e0e 100644
--- a/flang/lib/Optimizer/Transforms/ExternalNameConversion.cpp
+++ b/flang/lib/Optimizer/Transforms/ExternalNameConversion.cpp
@@ -6,7 +6,7 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "flang/Common/Fortran.h"
+#include "flang/Support/Fortran.h"
 #include "flang/Optimizer/Dialect/FIRDialect.h"
 #include "flang/Optimizer/Dialect/FIROps.h"
 #include "flang/Optimizer/Dialect/FIROpsSupport.h"
diff --git a/flang/lib/Optimizer/Transforms/LoopVersioning.cpp b/flang/lib/Optimizer/Transforms/LoopVersioning.cpp
index 51dc48f0fcb129..f6bd2aeb17bc20 100644
--- a/flang/lib/Optimizer/Transforms/LoopVersioning.cpp
+++ b/flang/lib/Optimizer/Transforms/LoopVersioning.cpp
@@ -40,7 +40,7 @@
 ///       could be part of the cost analysis above.
 //===----------------------------------------------------------------------===//
 
-#include "flang/ISO_Fortran_binding_wrapper.h"
+#include "flang/Common/ISO_Fortran_binding_wrapper.h"
 #include "flang/Optimizer/Builder/BoxValue.h"
 #include "flang/Optimizer/Builder/FIRBuilder.h"
 #include "flang/Optimizer/Builder/Runtime/Inquiry.h"
diff --git a/flang/lib/Optimizer/Transforms/SimplifyIntrinsics.cpp b/flang/lib/Optimizer/Transforms/SimplifyIntrinsics.cpp
index c61179a7460e32..c56dfa1cdfb524 100644
--- a/flang/lib/Optimizer/Transforms/SimplifyIntrinsics.cpp
+++ b/flang/lib/Optimizer/Transforms/SimplifyIntrinsics.cpp
@@ -22,7 +22,7 @@
 /// and small in size.
 //===----------------------------------------------------------------------===//
 
-#include "flang/Common/Fortran.h"
+#include "flang/Support/Fortran.h"
 #include "flang/Optimizer/Builder/BoxValue.h"
 #include "flang/Optimizer/Builder/FIRBuilder.h"
 #include "flang/Optimizer/Builder/LowLevelIntrinsics.h"
diff --git a/flang/lib/Optimizer/Transforms/StackReclaim.cpp b/flang/lib/Optimizer/Transforms/StackReclaim.cpp
index 8a60a9e64f704b..629ba587adf3ca 100644
--- a/flang/lib/Optimizer/Transforms/StackReclaim.cpp
+++ b/flang/lib/Optimizer/Transforms/StackReclaim.cpp
@@ -6,7 +6,7 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "flang/Common/Fortran.h"
+#include "flang/Support/Fortran.h"
 #include "flang/Optimizer/Dialect/FIRDialect.h"
 #include "flang/Optimizer/Dialect/FIROps.h"
 #include "flang/Optimizer/Transforms/Passes.h"
diff --git a/flang/lib/Optimizer/Transforms/VScaleAttr.cpp b/flang/lib/Optimizer/Transforms/VScaleAttr.cpp
index d311167c58b4d6..54a2456e77366c 100644
--- a/flang/lib/Optimizer/Transforms/VScaleAttr.cpp
+++ b/flang/lib/Optimizer/Transforms/VScaleAttr.cpp
@@ -14,7 +14,7 @@
 /// likely harmless to run it on something else, but it is also not valuable].
 //===----------------------------------------------------------------------===//
 
-#include "flang/ISO_Fortran_binding_wrapper.h"
+#include "flang/Common/ISO_Fortran_binding_wrapper.h"
 #include "flang/Optimizer/Builder/BoxValue.h"
 #include "flang/Optimizer/Builder/FIRBuilder.h"
 #include "flang/Optimizer/Builder/Runtime/Inquiry.h"
diff --git a/flang/lib/Parser/CMakeLists.txt b/flang/lib/Parser/CMakeLists.txt
index 600a2f67df4431..b2cd3cbbe35ffc 100644
--- a/flang/lib/Parser/CMakeLists.txt
+++ b/flang/lib/Parser/CMakeLists.txt
@@ -25,7 +25,7 @@ add_flang_library(FortranParser
   user-state.cpp
 
   LINK_LIBS
-  FortranCommon
+  FortranSupport
 
   LINK_COMPONENTS
   Support
diff --git a/flang/lib/Parser/basic-parsers.h b/flang/lib/Parser/basic-parsers.h
index 515b5993d67376..6575c7d01de346 100644
--- a/flang/lib/Parser/basic-parsers.h
+++ b/flang/lib/Parser/basic-parsers.h
@@ -22,9 +22,9 @@
 // This header defines the fundamental parser class templates and helper
 // template functions.  See parser-combinators.txt for documentation.
 
-#include "flang/Common/Fortran-features.h"
+#include "flang/Support/Fortran-features.h"
 #include "flang/Common/idioms.h"
-#include "flang/Common/indirection.h"
+#include "flang/Support/indirection.h"
 #include "flang/Parser/char-block.h"
 #include "flang/Parser/message.h"
 #include "flang/Parser/parse-state.h"
diff --git a/flang/lib/Parser/parse-tree.cpp b/flang/lib/Parser/parse-tree.cpp
index 7f0899aaa14294..3b90a57c602945 100644
--- a/flang/lib/Parser/parse-tree.cpp
+++ b/flang/lib/Parser/parse-tree.cpp
@@ -8,7 +8,7 @@
 
 #include "flang/Parser/parse-tree.h"
 #include "flang/Common/idioms.h"
-#include "flang/Common/indirection.h"
+#include "flang/Support/indirection.h"
 #include "flang/Parser/tools.h"
 #include "flang/Parser/user-state.h"
 #include "llvm/Support/raw_ostream.h"
diff --git a/flang/lib/Parser/prescan.h b/flang/lib/Parser/prescan.h
index 9d4f7c0c302a1a..0ea614d1df3bd9 100644
--- a/flang/lib/Parser/prescan.h
+++ b/flang/lib/Parser/prescan.h
@@ -16,7 +16,7 @@
 // fixed form character literals on truncated card images, file
 // inclusion, and driving the Fortran source preprocessor.
 
-#include "flang/Common/Fortran-features.h"
+#include "flang/Support/Fortran-features.h"
 #include "flang/Parser/characters.h"
 #include "flang/Parser/message.h"
 #include "flang/Parser/provenance.h"
diff --git a/flang/lib/Parser/unparse.cpp b/flang/lib/Parser/unparse.cpp
index 2511a5dda9d095..7b0385c63cd8a1 100644
--- a/flang/lib/Parser/unparse.cpp
+++ b/flang/lib/Parser/unparse.cpp
@@ -10,9 +10,9 @@
 // traversal templates in parse-tree-visitor.h.
 
 #include "flang/Parser/unparse.h"
-#include "flang/Common/Fortran.h"
+#include "flang/Support/Fortran.h"
 #include "flang/Common/idioms.h"
-#include "flang/Common/indirection.h"
+#include "flang/Support/indirection.h"
 #include "flang/Parser/characters.h"
 #include "flang/Parser/parse-tree-visitor.h"
 #include "flang/Parser/parse-tree.h"
diff --git a/flang/lib/Semantics/CMakeLists.txt b/flang/lib/Semantics/CMakeLists.txt
index 41406ecf50e004..4203648a50ef71 100644
--- a/flang/lib/Semantics/CMakeLists.txt
+++ b/flang/lib/Semantics/CMakeLists.txt
@@ -52,7 +52,7 @@ add_flang_library(FortranSemantics
   omp_gen
 
   LINK_LIBS
-  FortranCommon
+  FortranSupport
   FortranParser
   FortranEvaluate
 
diff --git a/flang/lib/Semantics/assignment.h b/flang/lib/Semantics/assignment.h
index 95d7b3cf91b17a..275625d3ed6522 100644
--- a/flang/lib/Semantics/assignment.h
+++ b/flang/lib/Semantics/assignment.h
@@ -9,7 +9,7 @@
 #ifndef FORTRAN_SEMANTICS_ASSIGNMENT_H_
 #define FORTRAN_SEMANTICS_ASSIGNMENT_H_
 
-#include "flang/Common/indirection.h"
+#include "flang/Support/indirection.h"
 #include "flang/Evaluate/expression.h"
 #include "flang/Semantics/semantics.h"
 
diff --git a/flang/lib/Semantics/check-case.cpp b/flang/lib/Semantics/check-case.cpp
index d296460127e12c..0e38b24f1b319d 100644
--- a/flang/lib/Semantics/check-case.cpp
+++ b/flang/lib/Semantics/check-case.cpp
@@ -8,8 +8,8 @@
 
 #include "check-case.h"
 #include "flang/Common/idioms.h"
-#include "flang/Common/reference.h"
-#include "flang/Common/template.h"
+#include "flang/Support/reference.h"
+#include "flang/Support/template.h"
 #include "flang/Evaluate/fold.h"
 #include "flang/Evaluate/type.h"
 #include "flang/Parser/parse-tree.h"
diff --git a/flang/lib/Semantics/check-coarray.cpp b/flang/lib/Semantics/check-coarray.cpp
index 6cf61a6b923db3..d34c70e60d966b 100644
--- a/flang/lib/Semantics/check-coarray.cpp
+++ b/flang/lib/Semantics/check-coarray.cpp
@@ -7,7 +7,7 @@
 //===----------------------------------------------------------------------===//
 
 #include "check-coarray.h"
-#include "flang/Common/indirection.h"
+#include "flang/Support/indirection.h"
 #include "flang/Evaluate/expression.h"
 #include "flang/Parser/message.h"
 #include "flang/Parser/parse-tree.h"
diff --git a/flang/lib/Semantics/check-cuda.cpp b/flang/lib/Semantics/check-cuda.cpp
index d8bd435bf09f38..738a471f4d01f5 100644
--- a/flang/lib/Semantics/check-cuda.cpp
+++ b/flang/lib/Semantics/check-cuda.cpp
@@ -7,7 +7,7 @@
 //===----------------------------------------------------------------------===//
 
 #include "check-cuda.h"
-#include "flang/Common/template.h"
+#include "flang/Support/template.h"
 #include "flang/Evaluate/fold.h"
 #include "flang/Evaluate/tools.h"
 #include "flang/Evaluate/traverse.h"
diff --git a/flang/lib/Semantics/check-data.h b/flang/lib/Semantics/check-data.h
index 479d32568fa66a..5cdf46a5ffb1c9 100644
--- a/flang/lib/Semantics/check-data.h
+++ b/flang/lib/Semantics/check-data.h
@@ -10,7 +10,7 @@
 #define FORTRAN_SEMANTICS_CHECK_DATA_H_
 
 #include "data-to-inits.h"
-#include "flang/Common/interval.h"
+#include "flang/Support/interval.h"
 #include "flang/Evaluate/fold-designator.h"
 #include "flang/Evaluate/initial-image.h"
 #include "flang/Semantics/expression.h"
diff --git a/flang/lib/Semantics/check-do-forall.cpp b/flang/lib/Semantics/check-do-forall.cpp
index d798244ff1ef2d..42e1c07fc45c3e 100644
--- a/flang/lib/Semantics/check-do-forall.cpp
+++ b/flang/lib/Semantics/check-do-forall.cpp
@@ -8,7 +8,7 @@
 
 #include "check-do-forall.h"
 #include "definable.h"
-#include "flang/Common/template.h"
+#include "flang/Support/template.h"
 #include "flang/Evaluate/call.h"
 #include "flang/Evaluate/expression.h"
 #include "flang/Evaluate/tools.h"
diff --git a/flang/lib/Semantics/check-return.cpp b/flang/lib/Semantics/check-return.cpp
index ec2600bac3c68e..6a03467a27a759 100644
--- a/flang/lib/Semantics/check-return.cpp
+++ b/flang/lib/Semantics/check-return.cpp
@@ -7,7 +7,7 @@
 //===----------------------------------------------------------------------===//
 
 #include "check-return.h"
-#include "flang/Common/Fortran-features.h"
+#include "flang/Support/Fortran-features.h"
 #include "flang/Parser/message.h"
 #include "flang/Parser/parse-tree.h"
 #include "flang/Semantics/semantics.h"
diff --git a/flang/lib/Semantics/check-select-rank.cpp b/flang/lib/Semantics/check-select-rank.cpp
index 2e602d307013c1..722226465b6642 100644
--- a/flang/lib/Semantics/check-select-rank.cpp
+++ b/flang/lib/Semantics/check-select-rank.cpp
@@ -7,7 +7,7 @@
 //===----------------------------------------------------------------------===//
 
 #include "check-select-rank.h"
-#include "flang/Common/Fortran.h"
+#include "flang/Support/Fortran.h"
 #include "flang/Common/idioms.h"
 #include "flang/Parser/message.h"
 #include "flang/Parser/tools.h"
diff --git a/flang/lib/Semantics/check-select-type.cpp b/flang/lib/Semantics/check-select-type.cpp
index 94d16a719277af..da41410bd24612 100644
--- a/flang/lib/Semantics/check-select-type.cpp
+++ b/flang/lib/Semantics/check-select-type.cpp
@@ -8,7 +8,7 @@
 
 #include "check-select-type.h"
 #include "flang/Common/idioms.h"
-#include "flang/Common/reference.h"
+#include "flang/Support/reference.h"
 #include "flang/Evaluate/fold.h"
 #include "flang/Evaluate/type.h"
 #include "flang/Parser/parse-tree.h"
diff --git a/flang/lib/Semantics/check-stop.cpp b/flang/lib/Semantics/check-stop.cpp
index 43535b07f029e9..dab076424bd8e6 100644
--- a/flang/lib/Semantics/check-stop.cpp
+++ b/flang/lib/Semantics/check-stop.cpp
@@ -7,7 +7,7 @@
 //===----------------------------------------------------------------------===//
 
 #include "check-stop.h"
-#include "flang/Common/Fortran.h"
+#include "flang/Support/Fortran.h"
 #include "flang/Evaluate/expression.h"
 #include "flang/Parser/parse-tree.h"
 #include "flang/Semantics/semantics.h"
diff --git a/flang/lib/Semantics/data-to-inits.h b/flang/lib/Semantics/data-to-inits.h
index d8cc4601de26fa..df4d552760eda6 100644
--- a/flang/lib/Semantics/data-to-inits.h
+++ b/flang/lib/Semantics/data-to-inits.h
@@ -9,8 +9,8 @@
 #ifndef FORTRAN_SEMANTICS_DATA_TO_INITS_H_
 #define FORTRAN_SEMANTICS_DATA_TO_INITS_H_
 
-#include "flang/Common/default-kinds.h"
-#include "flang/Common/interval.h"
+#include "flang/Support/default-kinds.h"
+#include "flang/Support/interval.h"
 #include "flang/Evaluate/fold-designator.h"
 #include "flang/Evaluate/initial-image.h"
 #include <list>
diff --git a/flang/lib/Semantics/expression.cpp b/flang/lib/Semantics/expression.cpp
index 072ebe172f45a9..a4be06515e4c87 100644
--- a/flang/lib/Semantics/expression.cpp
+++ b/flang/lib/Semantics/expression.cpp
@@ -11,7 +11,7 @@
 #include "pointer-assignment.h"
 #include "resolve-names-utils.h"
 #include "resolve-names.h"
-#include "flang/Common/Fortran.h"
+#include "flang/Support/Fortran.h"
 #include "flang/Common/idioms.h"
 #include "flang/Evaluate/common.h"
 #include "flang/Evaluate/fold.h"
diff --git a/flang/lib/Semantics/pointer-assignment.cpp b/flang/lib/Semantics/pointer-assignment.cpp
index 4948fce77a2502..abd3c5f461cb7e 100644
--- a/flang/lib/Semantics/pointer-assignment.cpp
+++ b/flang/lib/Semantics/pointer-assignment.cpp
@@ -10,7 +10,7 @@
 #include "definable.h"
 #include "flang/Common/idioms.h"
 #include "flang/Common/restorer.h"
-#include "flang/Common/template.h"
+#include "flang/Support/template.h"
 #include "flang/Evaluate/characteristics.h"
 #include "flang/Evaluate/expression.h"
 #include "flang/Evaluate/fold.h"
diff --git a/flang/lib/Semantics/resolve-labels.cpp b/flang/lib/Semantics/resolve-labels.cpp
index e5e96ec6327e2b..84d2e51d438bfe 100644
--- a/flang/lib/Semantics/resolve-labels.cpp
+++ b/flang/lib/Semantics/resolve-labels.cpp
@@ -8,7 +8,7 @@
 
 #include "resolve-labels.h"
 #include "flang/Common/enum-set.h"
-#include "flang/Common/template.h"
+#include "flang/Support/template.h"
 #include "flang/Parser/parse-tree-visitor.h"
 #include "flang/Semantics/semantics.h"
 #include <cstdarg>
diff --git a/flang/lib/Semantics/resolve-names-utils.cpp b/flang/lib/Semantics/resolve-names-utils.cpp
index 39392257938d66..bc5f458f403cf2 100644
--- a/flang/lib/Semantics/resolve-names-utils.cpp
+++ b/flang/lib/Semantics/resolve-names-utils.cpp
@@ -7,10 +7,10 @@
 //===----------------------------------------------------------------------===//
 
 #include "resolve-names-utils.h"
-#include "flang/Common/Fortran-features.h"
-#include "flang/Common/Fortran.h"
+#include "flang/Support/Fortran-features.h"
+#include "flang/Support/Fortran.h"
 #include "flang/Common/idioms.h"
-#include "flang/Common/indirection.h"
+#include "flang/Support/indirection.h"
 #include "flang/Evaluate/fold.h"
 #include "flang/Evaluate/tools.h"
 #include "flang/Evaluate/traverse.h"
diff --git a/flang/lib/Semantics/resolve-names.cpp b/flang/lib/Semantics/resolve-names.cpp
index d8f601212d8d01..920cefa084e05c 100644
--- a/flang/lib/Semantics/resolve-names.cpp
+++ b/flang/lib/Semantics/resolve-names.cpp
@@ -14,9 +14,9 @@
 #include "resolve-directives.h"
 #include "resolve-names-utils.h"
 #include "rewrite-parse-tree.h"
-#include "flang/Common/Fortran.h"
-#include "flang/Common/default-kinds.h"
-#include "flang/Common/indirection.h"
+#include "flang/Support/Fortran.h"
+#include "flang/Support/default-kinds.h"
+#include "flang/Support/indirection.h"
 #include "flang/Common/restorer.h"
 #include "flang/Common/visit.h"
 #include "flang/Evaluate/characteristics.h"
diff --git a/flang/lib/Semantics/rewrite-parse-tree.cpp b/flang/lib/Semantics/rewrite-parse-tree.cpp
index b4fb72ce213017..46641f5bd3c363 100644
--- a/flang/lib/Semantics/rewrite-parse-tree.cpp
+++ b/flang/lib/Semantics/rewrite-parse-tree.cpp
@@ -8,7 +8,7 @@
 
 #include "rewrite-parse-tree.h"
 #include "rewrite-directives.h"
-#include "flang/Common/indirection.h"
+#include "flang/Support/indirection.h"
 #include "flang/Parser/parse-tree-visitor.h"
 #include "flang/Parser/parse-tree.h"
 #include "flang/Parser/tools.h"
diff --git a/flang/lib/Semantics/semantics.cpp b/flang/lib/Semantics/semantics.cpp
index 8592d1e5d6217e..c39c8ac5a7b111 100644
--- a/flang/lib/Semantics/semantics.cpp
+++ b/flang/lib/Semantics/semantics.cpp
@@ -37,7 +37,7 @@
 #include "resolve-labels.h"
 #include "resolve-names.h"
 #include "rewrite-parse-tree.h"
-#include "flang/Common/default-kinds.h"
+#include "flang/Support/default-kinds.h"
 #include "flang/Parser/parse-tree-visitor.h"
 #include "flang/Parser/tools.h"
 #include "flang/Semantics/expression.h"
diff --git a/flang/lib/Semantics/tools.cpp b/flang/lib/Semantics/tools.cpp
index 8d16ab71008766..2aa0476b8fa07a 100644
--- a/flang/lib/Semantics/tools.cpp
+++ b/flang/lib/Semantics/tools.cpp
@@ -7,8 +7,8 @@
 //===----------------------------------------------------------------------===//
 
 #include "flang/Parser/tools.h"
-#include "flang/Common/Fortran.h"
-#include "flang/Common/indirection.h"
+#include "flang/Support/Fortran.h"
+#include "flang/Support/indirection.h"
 #include "flang/Parser/dump-parse-tree.h"
 #include "flang/Parser/message.h"
 #include "flang/Parser/parse-tree.h"
diff --git a/flang/lib/Support/CMakeLists.txt b/flang/lib/Support/CMakeLists.txt
new file mode 100644
index 00000000000000..674ed0f196c89e
--- /dev/null
+++ b/flang/lib/Support/CMakeLists.txt
@@ -0,0 +1,56 @@
+#===-- lib/Support/CMakeLists.txt ------------------------------------------===#
+#
+# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+# See https://llvm.org/LICENSE.txt for license information.
+# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+#
+#===------------------------------------------------------------------------===#
+
+find_first_existing_vc_file("${LLVM_MAIN_SRC_DIR}" llvm_vc)
+find_first_existing_vc_file("${FLANG_SOURCE_DIR}" flang_vc)
+
+# The VC revision include that we want to generate.
+set(version_inc "${CMAKE_CURRENT_BINARY_DIR}/VCSVersion.inc")
+
+set(generate_vcs_version_script "${LLVM_CMAKE_DIR}/GenerateVersionFromVCS.cmake")
+
+if(llvm_vc AND LLVM_APPEND_VC_REV)
+  set(llvm_source_dir ${LLVM_MAIN_SRC_DIR})
+endif()
+if(flang_vc AND LLVM_APPEND_VC_REV)
+  set(flang_source_dir ${FLANG_SOURCE_DIR})
+endif()
+ 
+# Create custom target to generate the VC revision include.
+add_custom_command(OUTPUT "${version_inc}"
+  DEPENDS "${llvm_vc}" "${flang_vc}" "${generate_vcs_version_script}"
+  COMMAND ${CMAKE_COMMAND} "-DNAMES=\"LLVM;FLANG\""
+                           "-DLLVM_SOURCE_DIR=${llvm_source_dir}"
+                           "-DFLANG_SOURCE_DIR=${flang_source_dir}"
+                           "-DHEADER_FILE=${version_inc}"
+                           "-DLLVM_FORCE_VC_REVISION=${LLVM_FORCE_VC_REVISION}"
+                           "-DLLVM_FORCE_VC_REPOSITORY=${LLVM_FORCE_VC_REPOSITORY}"
+                           -P "${generate_vcs_version_script}")
+
+# Mark the generated header as being generated.
+set_source_files_properties("${version_inc}"
+  PROPERTIES GENERATED TRUE
+             HEADER_FILE_ONLY TRUE)
+
+if(FLANG_VENDOR)
+  set_source_files_properties(Version.cpp
+    PROPERTIES COMPILE_DEFINITIONS "FLANG_VENDOR=\"${FLANG_VENDOR} \"")
+endif()
+
+
+add_flang_library(FortranSupport
+  Fortran.cpp
+  Fortran-features.cpp
+  default-kinds.cpp
+  idioms.cpp
+  Version.cpp
+  ${version_inc}
+
+  LINK_COMPONENTS
+  Support
+)
diff --git a/flang/lib/Common/Fortran-features.cpp b/flang/lib/Support/Fortran-features.cpp
similarity index 91%
rename from flang/lib/Common/Fortran-features.cpp
rename to flang/lib/Support/Fortran-features.cpp
index 25a948818e6560..e49735218ab967 100644
--- a/flang/lib/Common/Fortran-features.cpp
+++ b/flang/lib/Support/Fortran-features.cpp
@@ -1,4 +1,4 @@
-//===-- lib/Common/Fortran-features.cpp -----------------------------------===//
+//===-- lib/Support/Fortran-features.cpp ------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -6,8 +6,8 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "flang/Common/Fortran-features.h"
-#include "flang/Common/Fortran.h"
+#include "flang/Support/Fortran-features.h"
+#include "flang/Support/Fortran.h"
 #include "flang/Common/idioms.h"
 
 namespace Fortran::common {
diff --git a/flang/lib/Common/Fortran.cpp b/flang/lib/Support/Fortran.cpp
similarity index 96%
rename from flang/lib/Common/Fortran.cpp
rename to flang/lib/Support/Fortran.cpp
index c014b1263a67f0..21eafe385015b5 100644
--- a/flang/lib/Common/Fortran.cpp
+++ b/flang/lib/Support/Fortran.cpp
@@ -1,4 +1,4 @@
-//===-- lib/Common/Fortran.cpp --------------------------------------------===//
+//===-- lib/Support/Fortran.cpp ---------------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -6,8 +6,8 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "flang/Common/Fortran.h"
-#include "flang/Common/Fortran-features.h"
+#include "flang/Support/Fortran.h"
+#include "flang/Support/Fortran-features.h"
 
 namespace Fortran::common {
 
diff --git a/flang/lib/Common/Version.cpp b/flang/lib/Support/Version.cpp
similarity index 95%
rename from flang/lib/Common/Version.cpp
rename to flang/lib/Support/Version.cpp
index d67255f353dfd7..8ee4908f28f621 100644
--- a/flang/lib/Common/Version.cpp
+++ b/flang/lib/Support/Version.cpp
@@ -1,4 +1,4 @@
-//===- Version.cpp - Flang Version Number -------------------*- Fortran -*-===//
+//===-- lib/Support/Version.cpp ---------------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -10,7 +10,7 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "flang/Common/Version.h"
+#include "flang/Support/Version.h"
 #include "llvm/Support/raw_ostream.h"
 #include <cstdlib>
 #include <cstring>
diff --git a/flang/lib/Support/big-radix-floating-point.h b/flang/lib/Support/big-radix-floating-point.h
new file mode 100644
index 00000000000000..4c3d8f8b30832a
--- /dev/null
+++ b/flang/lib/Support/big-radix-floating-point.h
@@ -0,0 +1,396 @@
+//===-- lib/Support/big-radix-floating-point.h ------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef FORTRAN_DECIMAL_BIG_RADIX_FLOATING_POINT_H_
+#define FORTRAN_DECIMAL_BIG_RADIX_FLOATING_POINT_H_
+
+// This is a helper class for use in floating-point conversions between
+// binary and decimal representations.  It holds a multiple-precision
+// integer value using digits of a radix that is a large even power of ten
+// (10,000,000,000,000,000 by default, 10**16).  These digits are accompanied
+// by a signed exponent that denotes multiplication by a power of ten.
+// The effective radix point is to the right of the digits (i.e., they do
+// not represent a fraction).
+//
+// The operations supported by this class are limited to those required
+// for conversions between binary and decimal representations; it is not
+// a general-purpose facility.
+
+#include "flang/Common/bit-population-count.h"
+#include "flang/Common/leading-zero-bit-count.h"
+#include "flang/Common/uint128.h"
+#include "flang/Support/binary-floating-point.h"
+#include "flang/Common/decimal.h"
+#include <cinttypes>
+#include <limits>
+#include <type_traits>
+
+// Some environments, viz. glibc 2.17, allow the macro HUGE
+// to leak out of <math.h>.
+#undef HUGE
+
+namespace Fortran::decimal {
+
+static constexpr std::uint64_t TenToThe(int power) {
+  return power <= 0 ? 1 : 10 * TenToThe(power - 1);
+}
+
+// 10**(LOG10RADIX + 3) must be < 2**wordbits, and LOG10RADIX must be
+// even, so that pairs of decimal digits do not straddle Digits.
+// So LOG10RADIX must be 16 or 6.
+template <int PREC, int LOG10RADIX = 16> class BigRadixFloatingPointNumber {
+public:
+  using Real = BinaryFloatingPointNumber<PREC>;
+  static constexpr int log10Radix{LOG10RADIX};
+
+private:
+  static constexpr std::uint64_t uint64Radix{TenToThe(log10Radix)};
+  static constexpr int minDigitBits{
+      64 - common::LeadingZeroBitCount(uint64Radix)};
+  using Digit = common::HostUnsignedIntType<minDigitBits>;
+  static constexpr Digit radix{uint64Radix};
+  static_assert(radix < std::numeric_limits<Digit>::max() / 1000,
+      "radix is somehow too big");
+  static_assert(radix > std::numeric_limits<Digit>::max() / 10000,
+      "radix is somehow too small");
+
+  // The base-2 logarithm of the least significant bit that can arise
+  // in a subnormal IEEE floating-point number.
+  static constexpr int minLog2AnyBit{
+      -Real::exponentBias - Real::binaryPrecision};
+
+  // The number of Digits needed to represent the smallest subnormal.
+  static constexpr int maxDigits{3 - minLog2AnyBit / log10Radix};
+
+public:
+  explicit RT_API_ATTRS BigRadixFloatingPointNumber(
+      enum FortranRounding rounding = RoundNearest)
+      : rounding_{rounding} {}
+
+  // Converts a binary floating point value.
+  explicit RT_API_ATTRS BigRadixFloatingPointNumber(
+      Real, enum FortranRounding = RoundNearest);
+
+  RT_API_ATTRS BigRadixFloatingPointNumber &SetToZero() {
+    isNegative_ = false;
+    digits_ = 0;
+    exponent_ = 0;
+    return *this;
+  }
+
+  RT_API_ATTRS bool IsInteger() const { return exponent_ >= 0; }
+
+  // Converts decimal floating-point to binary.
+  RT_API_ATTRS ConversionToBinaryResult<PREC> ConvertToBinary();
+
+  // Parses and converts to binary.  Handles leading spaces,
+  // "NaN", & optionally-signed "Inf".  Does not skip internal
+  // spaces.
+  // The argument is a reference to a pointer that is left
+  // pointing to the first character that wasn't parsed.
+  RT_API_ATTRS ConversionToBinaryResult<PREC> ConvertToBinary(
+      const char *&, const char *end = nullptr);
+
+  // Formats a decimal floating-point number to a user buffer.
+  // May emit "NaN" or "Inf", or an possibly-signed integer.
+  // No decimal point is written, but if it were, it would be
+  // after the last digit; the effective decimal exponent is
+  // returned as part of the result structure so that it can be
+  // formatted by the client.
+  RT_API_ATTRS ConversionToDecimalResult ConvertToDecimal(
+      char *, std::size_t, enum DecimalConversionFlags, int digits) const;
+
+  // Discard decimal digits not needed to distinguish this value
+  // from the decimal encodings of two others (viz., the nearest binary
+  // floating-point numbers immediately below and above this one).
+  // The last decimal digit may not be uniquely determined in all
+  // cases, and will be the mean value when that is so (e.g., if
+  // last decimal digit values 6-8 would all work, it'll be a 7).
+  // This minimization necessarily assumes that the value will be
+  // emitted and read back into the same (or less precise) format
+  // with default rounding to the nearest value.
+  RT_API_ATTRS void Minimize(
+      BigRadixFloatingPointNumber &&less, BigRadixFloatingPointNumber &&more);
+
+  template <typename STREAM> STREAM &Dump(STREAM &) const;
+
+private:
+  RT_API_ATTRS BigRadixFloatingPointNumber(
+      const BigRadixFloatingPointNumber &that)
+      : digits_{that.digits_}, exponent_{that.exponent_},
+        isNegative_{that.isNegative_}, rounding_{that.rounding_} {
+    for (int j{0}; j < digits_; ++j) {
+      digit_[j] = that.digit_[j];
+    }
+  }
+
+  RT_API_ATTRS bool IsZero() const {
+    // Don't assume normalization.
+    for (int j{0}; j < digits_; ++j) {
+      if (digit_[j] != 0) {
+        return false;
+      }
+    }
+    return true;
+  }
+
+  // Predicate: true when 10*value would cause a carry.
+  // (When this happens during decimal-to-binary conversion,
+  // there are more digits in the input string than can be
+  // represented precisely.)
+  RT_API_ATTRS bool IsFull() const {
+    return digits_ == digitLimit_ && digit_[digits_ - 1] >= radix / 10;
+  }
+
+  // Sets *this to an unsigned integer value.
+  // Returns any remainder.
+  template <typename UINT> RT_API_ATTRS UINT SetTo(UINT n) {
+    static_assert(
+        std::is_same_v<UINT, common::uint128_t> || std::is_unsigned_v<UINT>);
+    SetToZero();
+    while (n != 0) {
+      auto q{n / 10u};
+      if (n != q * 10) {
+        break;
+      }
+      ++exponent_;
+      n = q;
+    }
+    if constexpr (sizeof n < sizeof(Digit)) {
+      if (n != 0) {
+        digit_[digits_++] = n;
+      }
+      return 0;
+    } else {
+      while (n != 0 && digits_ < digitLimit_) {
+        auto q{n / radix};
+        digit_[digits_++] = static_cast<Digit>(n - q * radix);
+        n = q;
+      }
+      return n;
+    }
+  }
+
+  RT_API_ATTRS int RemoveLeastOrderZeroDigits() {
+    int remove{0};
+    if (digits_ > 0 && digit_[0] == 0) {
+      while (remove < digits_ && digit_[remove] == 0) {
+        ++remove;
+      }
+      if (remove >= digits_) {
+        digits_ = 0;
+      } else if (remove > 0) {
+#if defined __GNUC__ && __GNUC__ < 8
+        // (&& j + remove < maxDigits) was added to avoid GCC < 8 build failure
+        // on -Werror=array-bounds. This can be removed if -Werror is disable.
+        for (int j{0}; j + remove < digits_ && (j + remove < maxDigits); ++j) {
+#else
+        for (int j{0}; j + remove < digits_; ++j) {
+#endif
+          digit_[j] = digit_[j + remove];
+        }
+        digits_ -= remove;
+      }
+    }
+    return remove;
+  }
+
+  RT_API_ATTRS void RemoveLeadingZeroDigits() {
+    while (digits_ > 0 && digit_[digits_ - 1] == 0) {
+      --digits_;
+    }
+  }
+
+  RT_API_ATTRS void Normalize() {
+    RemoveLeadingZeroDigits();
+    exponent_ += RemoveLeastOrderZeroDigits() * log10Radix;
+  }
+
+  // This limited divisibility test only works for even divisors of the radix,
+  // which is fine since it's only ever used with 2 and 5.
+  template <int N> RT_API_ATTRS bool IsDivisibleBy() const {
+    static_assert(N > 1 && radix % N == 0, "bad modulus");
+    return digits_ == 0 || (digit_[0] % N) == 0;
+  }
+
+  template <unsigned DIVISOR> RT_API_ATTRS int DivideBy() {
+    Digit remainder{0};
+    for (int j{digits_ - 1}; j >= 0; --j) {
+      Digit q{digit_[j] / DIVISOR};
+      Digit nrem{digit_[j] - DIVISOR * q};
+      digit_[j] = q + (radix / DIVISOR) * remainder;
+      remainder = nrem;
+    }
+    return remainder;
+  }
+
+  RT_API_ATTRS void DivideByPowerOfTwo(int twoPow) { // twoPow <= log10Radix
+    Digit remainder{0};
+    auto mask{(Digit{1} << twoPow) - 1};
+    auto coeff{radix >> twoPow};
+    for (int j{digits_ - 1}; j >= 0; --j) {
+      auto nrem{digit_[j] & mask};
+      digit_[j] = (digit_[j] >> twoPow) + coeff * remainder;
+      remainder = nrem;
+    }
+  }
+
+  // Returns true on overflow
+  RT_API_ATTRS bool DivideByPowerOfTwoInPlace(int twoPow) {
+    if (digits_ > 0) {
+      while (twoPow > 0) {
+        int chunk{twoPow > log10Radix ? log10Radix : twoPow};
+        if ((digit_[0] & ((Digit{1} << chunk) - 1)) == 0) {
+          DivideByPowerOfTwo(chunk);
+          twoPow -= chunk;
+          continue;
+        }
+        twoPow -= chunk;
+        if (digit_[digits_ - 1] >> chunk != 0) {
+          if (digits_ == digitLimit_) {
+            return true; // overflow
+          }
+          digit_[digits_++] = 0;
+        }
+        auto remainder{digit_[digits_ - 1]};
+        exponent_ -= log10Radix;
+        auto coeff{radix >> chunk}; // precise; radix is (5*2)**log10Radix
+        auto mask{(Digit{1} << chunk) - 1};
+        for (int j{digits_ - 1}; j >= 1; --j) {
+          digit_[j] = (digit_[j - 1] >> chunk) + coeff * remainder;
+          remainder = digit_[j - 1] & mask;
+        }
+        digit_[0] = coeff * remainder;
+      }
+    }
+    return false; // no overflow
+  }
+
+  RT_API_ATTRS int AddCarry(int position = 0, int carry = 1) {
+    for (; position < digits_; ++position) {
+      Digit v{digit_[position] + carry};
+      if (v < radix) {
+        digit_[position] = v;
+        return 0;
+      }
+      digit_[position] = v - radix;
+      carry = 1;
+    }
+    if (digits_ < digitLimit_) {
+      digit_[digits_++] = carry;
+      return 0;
+    }
+    Normalize();
+    if (digits_ < digitLimit_) {
+      digit_[digits_++] = carry;
+      return 0;
+    }
+    return carry;
+  }
+
+  RT_API_ATTRS void Decrement() {
+    for (int j{0}; digit_[j]-- == 0; ++j) {
+      digit_[j] = radix - 1;
+    }
+  }
+
+  template <int N> RT_API_ATTRS int MultiplyByHelper(int carry = 0) {
+    for (int j{0}; j < digits_; ++j) {
+      auto v{N * digit_[j] + carry};
+      carry = v / radix;
+      digit_[j] = v - carry * radix; // i.e., v % radix
+    }
+    return carry;
+  }
+
+  template <int N> RT_API_ATTRS int MultiplyBy(int carry = 0) {
+    if (int newCarry{MultiplyByHelper<N>(carry)}) {
+      return AddCarry(digits_, newCarry);
+    } else {
+      return 0;
+    }
+  }
+
+  template <int N> RT_API_ATTRS int MultiplyWithoutNormalization() {
+    if (int carry{MultiplyByHelper<N>(0)}) {
+      if (digits_ < digitLimit_) {
+        digit_[digits_++] = carry;
+        return 0;
+      } else {
+        return carry;
+      }
+    } else {
+      return 0;
+    }
+  }
+
+  RT_API_ATTRS void LoseLeastSignificantDigit(); // with rounding
+
+  RT_API_ATTRS void PushCarry(int carry) {
+    if (digits_ == maxDigits && RemoveLeastOrderZeroDigits() == 0) {
+      LoseLeastSignificantDigit();
+      digit_[digits_ - 1] += carry;
+    } else {
+      digit_[digits_++] = carry;
+    }
+  }
+
+  // Adds another number and then divides by two.
+  // Assumes same exponent and sign.
+  // Returns true when the result has effectively been rounded down.
+  RT_API_ATTRS bool Mean(const BigRadixFloatingPointNumber &);
+
+  // Parses a floating-point number; leaves the pointer reference
+  // argument pointing at the next character after what was recognized.
+  // The "end" argument can be left null if the caller is sure that the
+  // string is properly terminated with an addressable character that
+  // can't be in a valid floating-point character.
+  RT_API_ATTRS bool ParseNumber(const char *&, bool &inexact, const char *end);
+
+  using Raw = typename Real::RawType;
+  constexpr RT_API_ATTRS Raw SignBit() const {
+    return Raw{isNegative_} << (Real::bits - 1);
+  }
+  constexpr RT_API_ATTRS Raw Infinity() const {
+    Raw result{static_cast<Raw>(Real::maxExponent)};
+    result <<= Real::significandBits;
+    result |= SignBit();
+    if constexpr (Real::bits == 80) { // x87
+      result |= Raw{1} << 63;
+    }
+    return result;
+  }
+  constexpr RT_API_ATTRS Raw NaN(bool isQuiet = true) {
+    Raw result{Real::maxExponent};
+    result <<= Real::significandBits;
+    result |= SignBit();
+    if constexpr (Real::bits == 80) { // x87
+      result |= Raw{isQuiet ? 3u : 2u} << 62;
+    } else {
+      Raw quiet{isQuiet ? Raw{2} : Raw{1}};
+      quiet <<= Real::significandBits - 2;
+      result |= quiet;
+    }
+    return result;
+  }
+  constexpr RT_API_ATTRS Raw HUGE() const {
+    Raw result{static_cast<Raw>(Real::maxExponent)};
+    result <<= Real::significandBits;
+    result |= SignBit();
+    return result - 1; // decrement exponent, set all significand bits
+  }
+
+  Digit digit_[maxDigits]; // in little-endian order: digit_[0] is LSD
+  int digits_{0}; // # of elements in digit_[] array; zero when zero
+  int digitLimit_{maxDigits}; // precision clamp
+  int exponent_{0}; // signed power of ten
+  bool isNegative_{false};
+  enum FortranRounding rounding_ { RoundNearest };
+};
+} // namespace Fortran::decimal
+#endif
diff --git a/flang/lib/Common/default-kinds.cpp b/flang/lib/Support/default-kinds.cpp
similarity index 94%
rename from flang/lib/Common/default-kinds.cpp
rename to flang/lib/Support/default-kinds.cpp
index 0c708fcd605094..612adceb9d996b 100644
--- a/flang/lib/Common/default-kinds.cpp
+++ b/flang/lib/Support/default-kinds.cpp
@@ -1,4 +1,4 @@
-//===-- lib/Common/default-kinds.cpp --------------------------------------===//
+//===-- lib/Support/default-kinds.cpp ---------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -6,7 +6,7 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "flang/Common/default-kinds.h"
+#include "flang/Support/default-kinds.h"
 #include "flang/Common/idioms.h"
 
 namespace Fortran::common {
diff --git a/flang/lib/Common/idioms.cpp b/flang/lib/Support/idioms.cpp
similarity index 89%
rename from flang/lib/Common/idioms.cpp
rename to flang/lib/Support/idioms.cpp
index 536a5c2e5479df..906a4c1bcd9b0a 100644
--- a/flang/lib/Common/idioms.cpp
+++ b/flang/lib/Support/idioms.cpp
@@ -1,4 +1,4 @@
-//===-- lib/Common/idioms.cpp ---------------------------------------------===//
+//===-- lib/Support/idioms.cpp ----------------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/CMakeLists.txt b/flang/runtime/CMakeLists.txt
deleted file mode 100644
index 4537b2d059d65b..00000000000000
--- a/flang/runtime/CMakeLists.txt
+++ /dev/null
@@ -1,314 +0,0 @@
-#===-- runtime/CMakeLists.txt ----------------------------------------------===#
-#
-# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-# See https://llvm.org/LICENSE.txt for license information.
-# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-#
-#===------------------------------------------------------------------------===#
-
-if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
-  cmake_minimum_required(VERSION 3.20.0)
-
-  project(FlangRuntime C CXX)
-
-  set(CMAKE_CXX_STANDARD 17)
-  set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
-  set(CMAKE_CXX_EXTENSIONS OFF)
-
-  set(FLANG_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/..")
-
-  set(LLVM_COMMON_CMAKE_UTILS "${FLANG_SOURCE_DIR}/../cmake")
-  set(LLVM_CMAKE_UTILS "${FLANG_SOURCE_DIR}/../llvm/cmake")
-  set(CLANG_CMAKE_UTILS "${FLANG_SOURCE_DIR}/../clang/cmake")
-
-  # Add path for custom modules
-  list(INSERT CMAKE_MODULE_PATH 0
-    "${FLANG_SOURCE_DIR}/cmake"
-    "${FLANG_SOURCE_DIR}/cmake/modules"
-    "${LLVM_COMMON_CMAKE_UTILS}"
-    "${LLVM_COMMON_CMAKE_UTILS}/Modules"
-    "${LLVM_CMAKE_UTILS}"
-    "${LLVM_CMAKE_UTILS}/modules"
-    "${CLANG_CMAKE_UTILS}/modules"
-    )
-
-  include(AddClang)
-  include(AddLLVM)
-  include(AddFlang)
-  include(HandleLLVMOptions)
-
-  include(TestBigEndian)
-  test_big_endian(IS_BIGENDIAN)
-  if (IS_BIGENDIAN)
-    add_compile_definitions(FLANG_BIG_ENDIAN=1)
-  else ()
-    add_compile_definitions(FLANG_LITTLE_ENDIAN=1)
-  endif ()
-  include_directories(BEFORE
-    ${FLANG_SOURCE_DIR}/include)
-
-  # The out of tree builds of the compiler and the Fortran runtime
-  # must use the same setting of FLANG_RUNTIME_F128_MATH_LIB
-  # to be composable. Failure to synchronize this setting may result
-  # in linking errors or fatal failures in F128 runtime functions.
-  set(FLANG_RUNTIME_F128_MATH_LIB "" CACHE STRING
-    "Specifies the target library used for implementing IEEE-754 128-bit float \
-    math in F18 runtime, e.g. it might be libquadmath for targets where \
-    REAL(16) is mapped to __float128, or libm for targets where REAL(16) \
-    is mapped to long double, etc."
-    )
-endif()
-
-include(CheckCXXSymbolExists)
-include(CheckCXXSourceCompiles)
-check_cxx_symbol_exists(strerror_r string.h HAVE_STRERROR_R)
-# Can't use symbol exists here as the function is overloaded in C++
-check_cxx_source_compiles(
-  "#include <string.h>
-   int main() {
-     char buf[4096];
-     return strerror_s(buf, 4096, 0);
-   }
-  "
-  HAVE_DECL_STRERROR_S)
-
-# Check if 128-bit float computations can be done via long double.
-check_cxx_source_compiles(
-  "#include <cfloat>
-   #if LDBL_MANT_DIG != 113
-   #error LDBL_MANT_DIG != 113
-   #endif
-   int main() { return 0; }
-  "
-  HAVE_LDBL_MANT_DIG_113)
-
-check_cxx_compiler_flag(-fno-lto FLANG_RUNTIME_HAS_FNO_LTO_FLAG)
-if (FLANG_RUNTIME_HAS_FNO_LTO_FLAG)
-  set(NO_LTO_FLAGS "-fno-lto")
-else()
-  set(NO_LTO_FLAGS "")
-endif()
-
-configure_file(config.h.cmake config.h)
-# include_directories is used here instead of target_include_directories
-# because add_flang_library creates multiple objects (STATIC/SHARED, OBJECT)
-# with different names
-include_directories(AFTER ${CMAKE_CURRENT_BINARY_DIR})
-
-append(${NO_LTO_FLAGS} CMAKE_C_FLAGS)
-append(${NO_LTO_FLAGS} CMAKE_CXX_FLAGS)
-
-# Disable libstdc++/libc++ assertions, even in an LLVM_ENABLE_ASSERTIONS build,
-# to avoid an unwanted dependency on libstdc++/libc++.so.
-add_definitions(-U_GLIBCXX_ASSERTIONS)
-add_definitions(-U_LIBCPP_ENABLE_ASSERTIONS)
-
-add_subdirectory(Float128Math)
-
-set(sources
-  ISO_Fortran_binding.cpp
-  allocator-registry.cpp
-  allocatable.cpp
-  array-constructor.cpp
-  assign.cpp
-  buffer.cpp
-  character.cpp
-  command.cpp
-  complex-powi.cpp
-  complex-reduction.c
-  connection.cpp
-  copy.cpp
-  derived-api.cpp
-  derived.cpp
-  descriptor-io.cpp
-  descriptor.cpp
-  dot-product.cpp
-  edit-input.cpp
-  edit-output.cpp
-  environment.cpp
-  exceptions.cpp
-  execute.cpp
-  extensions.cpp
-  external-unit.cpp
-  extrema.cpp
-  file.cpp
-  findloc.cpp
-  format.cpp
-  inquiry.cpp
-  internal-unit.cpp
-  io-api.cpp
-  io-api-minimal.cpp
-  io-error.cpp
-  io-stmt.cpp
-  iostat.cpp
-  main.cpp
-  matmul-transpose.cpp
-  matmul.cpp
-  memory.cpp
-  misc-intrinsic.cpp
-  namelist.cpp
-  non-tbp-dio.cpp
-  numeric.cpp
-  pointer.cpp
-  product.cpp
-  pseudo-unit.cpp
-  ragged.cpp
-  random.cpp
-  reduce.cpp
-  reduction.cpp
-  stat.cpp
-  stop.cpp
-  sum.cpp
-  support.cpp
-  temporary-stack.cpp
-  terminator.cpp
-  time-intrinsic.cpp
-  tools.cpp
-  transformational.cpp
-  type-code.cpp
-  type-info.cpp
-  unit-map.cpp
-  unit.cpp
-  utf.cpp
-  ${FORTRAN_MODULE_OBJECTS}
-)
-
-include(AddFlangOffloadRuntime)
-
-# List of files that are buildable for all devices.
-set(supported_files
-  ISO_Fortran_binding.cpp
-  allocatable.cpp
-  allocator-registry.cpp
-  array-constructor.cpp
-  assign.cpp
-  buffer.cpp
-  character.cpp
-  connection.cpp
-  copy.cpp
-  derived-api.cpp
-  derived.cpp
-  descriptor.cpp
-  descriptor-io.cpp
-  dot-product.cpp
-  edit-input.cpp
-  edit-output.cpp
-  environment.cpp
-  extrema.cpp
-  external-unit.cpp
-  file.cpp
-  findloc.cpp
-  format.cpp
-  inquiry.cpp
-  internal-unit.cpp
-  io-api.cpp
-  io-api-minimal.cpp
-  io-error.cpp
-  io-stmt.cpp
-  iostat.cpp
-  matmul-transpose.cpp
-  matmul.cpp
-  memory.cpp
-  misc-intrinsic.cpp
-  namelist.cpp
-  non-tbp-dio.cpp
-  numeric.cpp
-  pointer.cpp
-  product.cpp
-  pseudo-unit.cpp
-  ragged.cpp
-  stat.cpp
-  sum.cpp
-  support.cpp
-  terminator.cpp
-  tools.cpp
-  transformational.cpp
-  type-code.cpp
-  type-info.cpp
-  unit.cpp
-  utf.cpp
-  )
-
-enable_cuda_compilation(FortranRuntime "${supported_files}")
-enable_omp_offload_compilation("${supported_files}")
-
-if (NOT TARGET FortranFloat128Math)
-  # If FortranFloat128Math is not defined, then we are not building
-  # standalone FortranFloat128Math library. Instead, include
-  # the relevant sources into FortranRuntime itself.
-  # The information is provided via FortranFloat128MathILib
-  # interface library.
-  get_target_property(f128_sources
-    FortranFloat128MathILib INTERFACE_SOURCES
-    )
-  if (f128_sources)
-    # The interface may define special macros for Float128Math files,
-    # so we need to propagate them.
-    get_target_property(f128_defs
-      FortranFloat128MathILib INTERFACE_COMPILE_DEFINITIONS
-      )
-    set_property(SOURCE ${f128_sources}
-      APPEND PROPERTY COMPILE_DEFINITIONS
-      ${f128_defs}
-      )
-    list(APPEND sources ${f128_sources})
-  endif()
-endif()
-
-if (NOT DEFINED MSVC)
-  add_flang_library(FortranRuntime
-    ${sources}
-    LINK_LIBS
-    FortranDecimal
-
-    INSTALL_WITH_TOOLCHAIN
-  )
-else()
-  add_flang_library(FortranRuntime
-    ${sources}
-    LINK_LIBS
-    FortranDecimal
-  )
-  set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreaded)
-  add_flang_library(FortranRuntime.static ${sources}
-    LINK_LIBS
-    FortranDecimal.static
-    INSTALL_WITH_TOOLCHAIN)
-  set_target_properties(FortranRuntime.static PROPERTIES FOLDER "Flang/Runtime Libraries")
-  set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreadedDLL)
-  add_flang_library(FortranRuntime.dynamic ${sources}
-    LINK_LIBS
-    FortranDecimal.dynamic
-    INSTALL_WITH_TOOLCHAIN)
-  set_target_properties(FortranRuntime.dynamic PROPERTIES FOLDER "Flang/Runtime Libraries")
-  set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreadedDebug)
-  add_flang_library(FortranRuntime.static_dbg ${sources}
-    LINK_LIBS
-    FortranDecimal.static_dbg
-    INSTALL_WITH_TOOLCHAIN)
-  set_target_properties(FortranRuntime.static_dbg PROPERTIES FOLDER "Flang/Runtime Libraries")
-  set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreadedDebugDLL)
-  add_flang_library(FortranRuntime.dynamic_dbg ${sources}
-    LINK_LIBS
-    FortranDecimal.dynamic_dbg
-    INSTALL_WITH_TOOLCHAIN)
-  set_target_properties(FortranRuntime.dynamic_dbg PROPERTIES FOLDER "Flang/Runtime Libraries")
-  add_dependencies(FortranRuntime FortranRuntime.static FortranRuntime.dynamic
-    FortranRuntime.static_dbg FortranRuntime.dynamic_dbg)
-endif()
-set_target_properties(FortranRuntime PROPERTIES FOLDER "Flang/Runtime Libraries")
-
-# If FortranRuntime is part of a Flang build (and not a separate build) then
-# add dependency to make sure that Fortran runtime library is being built after
-# we have the Flang compiler available.  This also includes the MODULE files
-# that compile when the 'flang-new' target is built.
-#
-# TODO: This is a workaround and should be updated when runtime build procedure
-# is changed to a regular runtime build.  See discussion in PR #95388.
-if (TARGET flang-new AND TARGET module_files)
-  add_dependencies(FortranRuntime flang-new module_files)
-endif()
-
-if (FLANG_CUF_RUNTIME)
-  add_subdirectory(CUDA)
-endif()
diff --git a/flang/test/CMakeLists.txt b/flang/test/CMakeLists.txt
index a18a5c6519eda4..60261ea352780a 100644
--- a/flang/test/CMakeLists.txt
+++ b/flang/test/CMakeLists.txt
@@ -63,7 +63,7 @@ set(FLANG_TEST_DEPENDS
   FileCheck
   count
   not
-  module_files
+#  module_files
   fir-opt
   tco
   bbc
@@ -71,8 +71,6 @@ set(FLANG_TEST_DEPENDS
   llvm-objdump
   llvm-readobj
   split-file
-  FortranRuntime
-  FortranDecimal
 )
 if (LLVM_ENABLE_PLUGINS AND NOT WIN32)
   list(APPEND FLANG_TEST_DEPENDS Bye)
diff --git a/flang/test/Driver/linker-flags.f90 b/flang/test/Driver/linker-flags.f90
index ac9500d7c45cec..fdeb95e4dd97c6 100644
--- a/flang/test/Driver/linker-flags.f90
+++ b/flang/test/Driver/linker-flags.f90
@@ -33,7 +33,7 @@
 ! SOLARIS-F128NONE-NOT: FortranFloat128Math
 ! UNIX-F128LIBQUADMATH-SAME: "-lFortranFloat128Math" "--as-needed" "-lquadmath" "--no-as-needed"
 ! SOLARIS-F128LIBQUADMATH-SAME: "-lFortranFloat128Math" "-z" "ignore" "-lquadmath" "-z" "record"
-! UNIX-SAME: "-lFortranRuntime" "-lFortranDecimal" "-lm"
+! UNIX-SAME: "-lFortranRuntime" "-lm"
 ! COMPILER-RT: "{{.*}}{{\\|/}}libclang_rt.builtins.a"
 
 ! DARWIN-LABEL:  "{{.*}}ld{{(\.exe)?}}"
@@ -41,20 +41,18 @@
 ! DARWIN-F128NONE-NOT: FortranFloat128Math
 ! DARWIN-F128LIBQUADMATH-SAME: "-lFortranFloat128Math" "--as-needed" "-lquadmath" "--no-as-needed"
 ! DARWIN-SAME: -lFortranRuntime
-! DARWIN-SAME: -lFortranDecimal
 
 ! HAIKU-LABEL:  "{{.*}}ld{{(\.exe)?}}"
 ! HAIKU-SAME: "[[object_file]]"
 ! HAIKU-F128NONE-NOT: FortranFloat128Math
 ! HAIKU-F128LIBQUADMATH-SAME: "-lFortranFloat128Math" "--as-needed" "-lquadmath" "--no-as-needed"
-! HAIKU-SAME: "-lFortranRuntime" "-lFortranDecimal"
+! HAIKU-SAME: "-lFortranRuntime"
 
 ! MINGW-LABEL:  "{{.*}}ld{{(\.exe)?}}"
 ! MINGW-SAME: "[[object_file]]"
 ! MINGW-F128NONE-NOT: FortranFloat128Math
 ! MINGW-F128LIBQUADMATH-SAME: "-lFortranFloat128Math" "--as-needed" "-lquadmath" "--no-as-needed"
 ! MINGW-SAME: -lFortranRuntime
-! MINGW-SAME: -lFortranDecimal
 
 ! NOTE: This also matches lld-link (when CLANG_DEFAULT_LINKER=lld) and
 !       any .exe suffix that is added when resolving to the full path of
diff --git a/flang/test/Driver/msvc-dependent-lib-flags.f90 b/flang/test/Driver/msvc-dependent-lib-flags.f90
index 765917f07d8e72..befe61fdadcd14 100644
--- a/flang/test/Driver/msvc-dependent-lib-flags.f90
+++ b/flang/test/Driver/msvc-dependent-lib-flags.f90
@@ -8,7 +8,6 @@
 ! MSVC-SAME: -D_MT
 ! MSVC-SAME: --dependent-lib=libcmt
 ! MSVC-SAME: --dependent-lib=FortranRuntime.static.lib
-! MSVC-SAME: --dependent-lib=FortranDecimal.static.lib
 
 ! MSVC-DEBUG: -fc1
 ! MSVC-DEBUG-SAME: --dependent-lib=clang_rt.builtins.lib
@@ -16,7 +15,6 @@
 ! MSVC-DEBUG-SAME: -D_DEBUG
 ! MSVC-DEBUG-SAME: --dependent-lib=libcmtd
 ! MSVC-DEBUG-SAME: --dependent-lib=FortranRuntime.static_dbg.lib
-! MSVC-DEBUG-SAME: --dependent-lib=FortranDecimal.static_dbg.lib
 
 ! MSVC-DLL: -fc1
 ! MSVC-DLL-SAME: --dependent-lib=clang_rt.builtins.lib
@@ -24,7 +22,6 @@
 ! MSVC-DLL-SAME: -D_DLL
 ! MSVC-DLL-SAME: --dependent-lib=msvcrt
 ! MSVC-DLL-SAME: --dependent-lib=FortranRuntime.dynamic.lib
-! MSVC-DLL-SAME: --dependent-lib=FortranDecimal.dynamic.lib
 
 ! MSVC-DLL-DEBUG: -fc1
 ! MSVC-DLL-DEBUG-SAME: --dependent-lib=clang_rt.builtins.lib
@@ -33,4 +30,3 @@
 ! MSVC-DLL-DEBUG-SAME: -D_DLL
 ! MSVC-DLL-DEBUG-SAME: --dependent-lib=msvcrtd
 ! MSVC-DLL-DEBUG-SAME: --dependent-lib=FortranRuntime.dynamic_dbg.lib
-! MSVC-DLL-DEBUG-SAME: --dependent-lib=FortranDecimal.dynamic_dbg.lib
diff --git a/flang/test/lib/CMakeLists.txt b/flang/test/lib/CMakeLists.txt
index fc6ef10fab1f5a..687b107844c651 100644
--- a/flang/test/lib/CMakeLists.txt
+++ b/flang/test/lib/CMakeLists.txt
@@ -1 +1,2 @@
+include_directories("${CMAKE_CURRENT_SOURCE_DIR}/../../../FortranRuntime/include")
 add_subdirectory(Analysis)
diff --git a/flang/test/lit.cfg.py b/flang/test/lit.cfg.py
index 4acbc0606d1977..48b03e34798792 100644
--- a/flang/test/lit.cfg.py
+++ b/flang/test/lit.cfg.py
@@ -163,29 +163,6 @@
         ToolSubst("%not_todo_abort_cmd", command=FindTool("not"), unresolved="fatal")
     )
 
-# Define some variables to help us test that the flang runtime doesn't depend on
-# the C++ runtime libraries. For this we need a C compiler. If for some reason
-# we don't have one, we can just disable the test.
-if config.cc:
-    libruntime = os.path.join(config.flang_lib_dir, "libFortranRuntime.a")
-    libdecimal = os.path.join(config.flang_lib_dir, "libFortranDecimal.a")
-    include = os.path.join(config.flang_src_dir, "include")
-
-    if (
-        os.path.isfile(libruntime)
-        and os.path.isfile(libdecimal)
-        and os.path.isdir(include)
-    ):
-        config.available_features.add("c-compiler")
-        tools.append(
-            ToolSubst(
-                "%cc", command=config.cc, extra_args=isysroot_flag, unresolved="fatal"
-            )
-        )
-        tools.append(ToolSubst("%libruntime", command=libruntime, unresolved="fatal"))
-        tools.append(ToolSubst("%libdecimal", command=libdecimal, unresolved="fatal"))
-        tools.append(ToolSubst("%include", command=include, unresolved="fatal"))
-
 # Add all the tools and their substitutions (if applicable). Use the search paths provided for
 # finding the tools.
 if config.flang_standalone_build:
diff --git a/flang/test/lit.site.cfg.py.in b/flang/test/lit.site.cfg.py.in
index d1a0ac763cf8a0..65864302fb7aec 100644
--- a/flang/test/lit.site.cfg.py.in
+++ b/flang/test/lit.site.cfg.py.in
@@ -21,7 +21,6 @@ config.python_executable = "@PYTHON_EXECUTABLE@"
 config.flang_standalone_build = @FLANG_STANDALONE_BUILD@
 config.has_plugins = @LLVM_ENABLE_PLUGINS@
 config.linked_bye_extension = @LLVM_BYE_LINK_INTO_TOOLS@
-config.cc = "@CMAKE_C_COMPILER@"
 config.osx_sysroot = path(r"@CMAKE_OSX_SYSROOT@")
 config.targets_to_build = "@TARGETS_TO_BUILD@"
 config.default_sysroot = "@DEFAULT_SYSROOT@"
diff --git a/flang/tools/CMakeLists.txt b/flang/tools/CMakeLists.txt
index 337545ae0d4d7a..c9f00c8cc6dbd6 100644
--- a/flang/tools/CMakeLists.txt
+++ b/flang/tools/CMakeLists.txt
@@ -7,7 +7,6 @@
 #===------------------------------------------------------------------------===#
 
 add_subdirectory(bbc)
-add_subdirectory(f18)
 add_subdirectory(flang-driver)
 add_subdirectory(tco)
 add_subdirectory(f18-parse-demo)
diff --git a/flang/tools/bbc/CMakeLists.txt b/flang/tools/bbc/CMakeLists.txt
index 69316d4dc61de3..68e4b59fd6eec5 100644
--- a/flang/tools/bbc/CMakeLists.txt
+++ b/flang/tools/bbc/CMakeLists.txt
@@ -6,6 +6,7 @@ AllTargetsInfos
 TargetParser
 )
 
+include_directories("${CMAKE_CURRENT_SOURCE_DIR}/../../../FortranRuntime/include")
 add_flang_tool(bbc bbc.cpp
 DEPENDS
 FIROptCodeGenPassIncGen
diff --git a/flang/tools/bbc/bbc.cpp b/flang/tools/bbc/bbc.cpp
index dcff4503f16571..e9ec6b7116e0aa 100644
--- a/flang/tools/bbc/bbc.cpp
+++ b/flang/tools/bbc/bbc.cpp
@@ -14,10 +14,10 @@
 ///
 //===----------------------------------------------------------------------===//
 
-#include "flang/Common/Fortran-features.h"
-#include "flang/Common/OpenMP-features.h"
-#include "flang/Common/Version.h"
-#include "flang/Common/default-kinds.h"
+#include "flang/Support/Fortran-features.h"
+#include "flang/Support/OpenMP-features.h"
+#include "flang/Support/Version.h"
+#include "flang/Support/default-kinds.h"
 #include "flang/Frontend/TargetOptions.h"
 #include "flang/Lower/Bridge.h"
 #include "flang/Lower/PFTBuilder.h"
diff --git a/flang/tools/f18-parse-demo/CMakeLists.txt b/flang/tools/f18-parse-demo/CMakeLists.txt
index df1f1d24a55e51..34f1bf048ad849 100644
--- a/flang/tools/f18-parse-demo/CMakeLists.txt
+++ b/flang/tools/f18-parse-demo/CMakeLists.txt
@@ -1,3 +1,5 @@
+include_directories("${CMAKE_CURRENT_SOURCE_DIR}/../../../FortranRuntime/include")
+
 set(LLVM_LINK_COMPONENTS
   FrontendOpenACC
   FrontendOpenMP
diff --git a/flang/tools/f18-parse-demo/f18-parse-demo.cpp b/flang/tools/f18-parse-demo/f18-parse-demo.cpp
index 3025dbd4dca4ab..691b6cebec9b51 100644
--- a/flang/tools/f18-parse-demo/f18-parse-demo.cpp
+++ b/flang/tools/f18-parse-demo/f18-parse-demo.cpp
@@ -21,8 +21,8 @@
 // scaffolding compiler driver that can test some semantic passes of the
 // F18 compiler under development.
 
-#include "flang/Common/Fortran-features.h"
-#include "flang/Common/default-kinds.h"
+#include "flang/Support/Fortran-features.h"
+#include "flang/Support/default-kinds.h"
 #include "flang/Parser/characters.h"
 #include "flang/Parser/dump-parse-tree.h"
 #include "flang/Parser/message.h"
diff --git a/flang/tools/f18/CMakeLists.txt b/flang/tools/f18/CMakeLists.txt
deleted file mode 100644
index 9d7b8633958cb7..00000000000000
--- a/flang/tools/f18/CMakeLists.txt
+++ /dev/null
@@ -1,173 +0,0 @@
-set(LLVM_LINK_COMPONENTS
-  FrontendOpenACC
-  FrontendOpenMP
-  Support
-  )
-
-# Define the list of Fortran module files that need to be compiled
-# to produce an object file for inclusion into the FortranRuntime
-# library.
-set(MODULES_WITH_IMPLEMENTATION
-  "iso_fortran_env_impl"
-)
-
-# Define the list of Fortran module files for which it is
-# sufficient to generate the module file via -fsyntax-only.
-set(MODULES_WITHOUT_IMPLEMENTATION
-  "__fortran_builtins"
-  "__fortran_ieee_exceptions"
-  "__fortran_type_info"
-  "__ppc_types"
-  "__ppc_intrinsics"
-  "mma"
-  "__cuda_builtins"
-  "cudadevice"
-  "ieee_arithmetic"
-  "ieee_exceptions"
-  "ieee_features"
-  "iso_c_binding"
-  "iso_fortran_env"
-)
-
-set(MODULES ${MODULES_WITH_IMPLEMENTATION} ${MODULES_WITHOUT_IMPLEMENTATION})
-
-# Check if 128-bit float computations can be done via long double.
-check_cxx_source_compiles(
-  "#include <cfloat>
-   #if LDBL_MANT_DIG != 113
-   #error LDBL_MANT_DIG != 113
-   #endif
-   int main() { return 0; }
-  "
-  HAVE_LDBL_MANT_DIG_113)
-
-# Figure out whether we can support REAL(KIND=16)
-if (FLANG_RUNTIME_F128_MATH_LIB)
-  set(FLANG_SUPPORT_R16 "1")
-elseif (HAVE_LDBL_MANT_DIG_113)
-  set(FLANG_SUPPORT_R16 "1")
-else()
-  set(FLANG_SUPPORT_R16 "0")
-endif()
-
-# Init variable to hold extra object files coming from the Fortran modules;
-# these module files will be contributed from the CMakeLists in flang/tools/f18.
-set(module_objects "")
-
-# Create module files directly from the top-level module source directory.
-# If CMAKE_CROSSCOMPILING, then the newly built flang-new executable was
-# cross compiled, and thus can't be executed on the build system and thus
-# can't be used for generating module files.
-if (NOT CMAKE_CROSSCOMPILING)
-  foreach(filename ${MODULES})
-    set(depends "")
-    set(opts "")
-    if(${filename} STREQUAL "__fortran_builtins" OR
-       ${filename} STREQUAL "__ppc_types")
-    elseif(${filename} STREQUAL "__ppc_intrinsics" OR
-           ${filename} STREQUAL "mma")
-      set(depends ${FLANG_INTRINSIC_MODULES_DIR}/__ppc_types.mod)
-    elseif(${filename} STREQUAL "cudadevice")
-      set(opts -fc1 -xcuda)
-      set(depends ${FLANG_INTRINSIC_MODULES_DIR}/__cuda_builtins.mod)
-    else()
-      set(depends ${FLANG_INTRINSIC_MODULES_DIR}/__fortran_builtins.mod)
-      if(${filename} STREQUAL "iso_fortran_env")
-        set(depends ${depends} ${FLANG_INTRINSIC_MODULES_DIR}/iso_fortran_env_impl.mod)
-      endif()
-      if(${filename} STREQUAL "ieee_arithmetic" OR
-         ${filename} STREQUAL "ieee_exceptions")
-        set(depends ${depends} ${FLANG_INTRINSIC_MODULES_DIR}/__fortran_ieee_exceptions.mod)
-      endif()
-    endif()
-    if(NOT ${filename} STREQUAL "__fortran_type_info" AND NOT ${filename} STREQUAL "__fortran_builtins")
-      set(depends ${depends} ${FLANG_INTRINSIC_MODULES_DIR}/__fortran_type_info.mod)
-    endif()
-
-    # The module contains PPC vector types that needs the PPC target.
-    if(${filename} STREQUAL "__ppc_intrinsics" OR
-       ${filename} STREQUAL "mma")
-      if (PowerPC IN_LIST LLVM_TARGETS_TO_BUILD)
-        set(opts "--target=ppc64le")
-      else()
-        # Do not compile PPC module if the target is not available.
-        continue()
-      endif()
-    endif()
-
-    set(decls "")
-    if (FLANG_SUPPORT_R16)
-      set(decls "-DFLANG_SUPPORT_R16")
-    endif()
-
-    # Some modules have an implementation part that needs to be added to the
-    # FortranRuntime library.
-    set(compile_with "-fsyntax-only")
-    set(object_output "")
-    set(include_in_link FALSE)
-    if(${filename} IN_LIST MODULES_WITH_IMPLEMENTATION)
-      set(object_output "${CMAKE_CURRENT_BINARY_DIR}/${filename}${CMAKE_CXX_OUTPUT_EXTENSION}")
-      set(compile_with -c -o ${object_output})
-      set(include_in_link TRUE)
-    endif()
-
-    set(base ${FLANG_INTRINSIC_MODULES_DIR}/${filename})
-    # TODO: We may need to flag this with conditional, in case Flang is built w/o OpenMP support
-    add_custom_command(OUTPUT ${base}.mod ${object_output}
-      COMMAND ${CMAKE_COMMAND} -E make_directory ${FLANG_INTRINSIC_MODULES_DIR}
-      COMMAND flang-new ${opts} ${decls} -cpp ${compile_with} -module-dir ${FLANG_INTRINSIC_MODULES_DIR}
-        ${FLANG_SOURCE_DIR}/module/${filename}.f90
-      DEPENDS flang-new ${FLANG_SOURCE_DIR}/module/${filename}.f90 ${FLANG_SOURCE_DIR}/module/__fortran_builtins.f90 ${depends}
-    )
-    list(APPEND MODULE_FILES ${base}.mod)
-    install(FILES ${base}.mod DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/flang")
-
-    # If a module has been compiled into an object file, add the file to
-    # the link line for the FortranRuntime library.
-    if(include_in_link)
-      list(APPEND module_objects ${object_output})
-    endif()
-  endforeach()
-
-  # Set a CACHE variable that is visible to the CMakeLists.txt in runtime/, so that
-  # the compiled Fortran modules can be added to the link line of the FortranRuntime
-  # library.
-  set(FORTRAN_MODULE_OBJECTS ${module_objects} CACHE INTERNAL "" FORCE)
-
-  # Special case for omp_lib.mod, because its source comes from openmp/runtime/src/include.
-  # It also produces two module files: omp_lib.mod and omp_lib_kinds.mod.  Compile these
-  # files only if OpenMP support has been configured.
-  if (LLVM_TOOL_OPENMP_BUILD)
-    message(STATUS "OpenMP runtime support enabled via LLVM_ENABLED_PROJECTS, building omp_lib.mod")
-    set(base ${FLANG_INTRINSIC_MODULES_DIR}/omp_lib)
-    add_custom_command(OUTPUT ${base}.mod ${base}_kinds.mod
-      COMMAND ${CMAKE_COMMAND} -E make_directory ${FLANG_INTRINSIC_MODULES_DIR}
-      COMMAND flang-new -cpp -fsyntax-only ${opts} -module-dir ${FLANG_INTRINSIC_MODULES_DIR}
-        ${CMAKE_BINARY_DIR}/projects/openmp/runtime/src/omp_lib.F90
-      DEPENDS flang-new ${FLANG_INTRINSIC_MODULES_DIR}/iso_c_binding.mod ${CMAKE_BINARY_DIR}/projects/openmp/runtime/src/omp_lib.F90 ${depends}
-    )
-    add_custom_command(OUTPUT ${base}.f18.mod
-      DEPENDS ${base}.mod
-      COMMAND ${CMAKE_COMMAND} -E copy ${base}.mod ${base}.f18.mod)
-      add_custom_command(OUTPUT ${base}_kinds.f18.mod
-        DEPENDS ${base}.mod
-        COMMAND ${CMAKE_COMMAND} -E copy ${base}_kinds.mod ${base}_kinds.f18.mod)
-    list(APPEND MODULE_FILES ${base}.mod ${base}.f18.mod ${base}_kinds.mod ${base}_kinds.f18.mod)
-    install(FILES ${base}.mod ${base}.f18.mod ${base}_kinds.mod ${base}_kinds.f18.mod DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/flang")
-  else()
-    message(STATUS "Not building omp_lib.mod, no OpenMP runtime in LLVM_ENABLED_PROJECTS")
-  endif()
-endif()
-
-add_custom_target(module_files ALL DEPENDS ${MODULE_FILES})
-set_target_properties(module_files PROPERTIES FOLDER "Flang/Resources")
-
-# TODO Move this to a more suitable location
-# Copy the generated omp_lib.h header file, if OpenMP support has been configured.
-if (LLVM_TOOL_OPENMP_BUILD)
-  message(STATUS "OpenMP runtime support enabled via LLVM_ENABLED_PROJECTS, building omp_lib.h")
-  file(COPY ${CMAKE_BINARY_DIR}/projects/openmp/runtime/src/omp_lib.h DESTINATION "${CMAKE_BINARY_DIR}/include/flang/OpenMP/" FILE_PERMISSIONS OWNER_READ OWNER_WRITE)
-  install(FILES ${CMAKE_BINARY_DIR}/include/flang/OpenMP/omp_lib.h DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/flang/OpenMP")
-else()
-  message(STATUS "Not copying omp_lib.h, no OpenMP runtime in LLVM_ENABLED_PROJECTS")
-endif()
diff --git a/flang/tools/f18/dump.cpp b/flang/tools/f18/dump.cpp
deleted file mode 100644
index f11b5aedf4c6af..00000000000000
--- a/flang/tools/f18/dump.cpp
+++ /dev/null
@@ -1,42 +0,0 @@
-//===-- tools/f18/dump.cpp ------------------------------------------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-// This file defines Dump routines available for calling from the debugger.
-// Each is based on operator<< for that type. There are overloadings for
-// reference and pointer, and for dumping to a provided raw_ostream or errs().
-
-#ifdef DEBUGF18
-
-#include "llvm/Support/raw_ostream.h"
-
-#define DEFINE_DUMP(ns, name) \
-  namespace ns { \
-  class name; \
-  llvm::raw_ostream &operator<<(llvm::raw_ostream &, const name &); \
-  } \
-  void Dump(llvm::raw_ostream &os, const ns::name &x) { os << x << '\n'; } \
-  void Dump(llvm::raw_ostream &os, const ns::name *x) { \
-    if (x == nullptr) \
-      os << "null\n"; \
-    else \
-      Dump(os, *x); \
-  } \
-  void Dump(const ns::name &x) { Dump(llvm::errs(), x); } \
-  void Dump(const ns::name *x) { Dump(llvm::errs(), *x); }
-
-namespace Fortran {
-DEFINE_DUMP(parser, Name)
-DEFINE_DUMP(parser, CharBlock)
-DEFINE_DUMP(semantics, Symbol)
-DEFINE_DUMP(semantics, Scope)
-DEFINE_DUMP(semantics, IntrinsicTypeSpec)
-DEFINE_DUMP(semantics, DerivedTypeSpec)
-DEFINE_DUMP(semantics, DeclTypeSpec)
-} // namespace Fortran
-
-#endif
diff --git a/flang/tools/fir-opt/CMakeLists.txt b/flang/tools/fir-opt/CMakeLists.txt
index 4c6dbf7d9c8c37..3723ac5d7b37d2 100644
--- a/flang/tools/fir-opt/CMakeLists.txt
+++ b/flang/tools/fir-opt/CMakeLists.txt
@@ -1,3 +1,4 @@
+include_directories("${CMAKE_CURRENT_SOURCE_DIR}/../../../FortranRuntime/include")
 add_flang_tool(fir-opt fir-opt.cpp)
 llvm_update_compile_flags(fir-opt)
 get_property(dialect_libs GLOBAL PROPERTY MLIR_DIALECT_LIBS)
@@ -19,6 +20,7 @@ target_link_libraries(fir-opt PRIVATE
   FIRCodeGen
   HLFIRDialect
   HLFIRTransforms
+  FortranCommon # FIXME: Dependency of something else
   FlangOpenMPTransforms
   FIRAnalysis
   ${test_libs}
diff --git a/flang/tools/flang-driver/CMakeLists.txt b/flang/tools/flang-driver/CMakeLists.txt
index 9f33cdfe3fa90f..a2ad672b9d48c9 100644
--- a/flang/tools/flang-driver/CMakeLists.txt
+++ b/flang/tools/flang-driver/CMakeLists.txt
@@ -1,6 +1,9 @@
 # Infrastructure to build flang driver entry point. Flang driver depends on
 # LLVM libraries.
 
+message("include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../../FortranRuntime/include)")
+include_directories("${CMAKE_CURRENT_SOURCE_DIR}/../../../FortranRuntime/include")
+
 # Set your project compile flags.
 link_directories(${LLVM_LIBRARY_DIR})
 
diff --git a/flang/tools/tco/CMakeLists.txt b/flang/tools/tco/CMakeLists.txt
index 698a398547c773..f308fb6acbe98b 100644
--- a/flang/tools/tco/CMakeLists.txt
+++ b/flang/tools/tco/CMakeLists.txt
@@ -2,6 +2,7 @@ set(LLVM_LINK_COMPONENTS
   Passes
 )
 
+include_directories("${CMAKE_CURRENT_SOURCE_DIR}/../../../FortranRuntime/include")
 add_flang_tool(tco tco.cpp)
 llvm_update_compile_flags(tco)
 get_property(dialect_libs GLOBAL PROPERTY MLIR_DIALECT_LIBS)
@@ -17,6 +18,7 @@ target_link_libraries(tco PRIVATE
   FIRBuilder
   HLFIRDialect
   HLFIRTransforms
+  FortranCommon
   FlangOpenMPTransforms
   ${dialect_libs}
   ${extension_libs}
diff --git a/flang/unittests/CMakeLists.txt b/flang/unittests/CMakeLists.txt
index 945067fed4f82d..f9953bd434d44e 100644
--- a/flang/unittests/CMakeLists.txt
+++ b/flang/unittests/CMakeLists.txt
@@ -1,40 +1,8 @@
-if (FLANG_EXPERIMENTAL_CUDA_RUNTIME)
-  # If Fortran runtime is built as CUDA library, the linking
-  # of targets that link FortranRuntime must be done
-  # with CUDA_RESOLVE_DEVICE_SYMBOLS.
-  # CUDA language must be enabled for CUDA_RESOLVE_DEVICE_SYMBOLS
-  # to take effect.
-  enable_language(CUDA)
-endif()
-
 add_custom_target(FlangUnitTests)
 set_target_properties(FlangUnitTests PROPERTIES FOLDER "Flang/Tests")
 
-function(add_flang_unittest_offload_properties target)
-  # Set CUDA_RESOLVE_DEVICE_SYMBOLS.
-  if (FLANG_EXPERIMENTAL_CUDA_RUNTIME)
-    set_target_properties(${target}
-      PROPERTIES CUDA_RESOLVE_DEVICE_SYMBOLS ON
-      )
-  endif()
-  # Enable OpenMP offload during linking. We may need to replace
-  # LINK_OPTIONS with COMPILE_OPTIONS when there are OpenMP offload
-  # unittests.
-  #
-  # FIXME: replace 'native' in --offload-arch option with the list
-  #        of targets that Fortran Runtime was built for.
-  #        Common code must be moved from flang/runtime/CMakeLists.txt.
-  if (NOT FLANG_EXPERIMENTAL_OMP_OFFLOAD_BUILD STREQUAL "off")
-    set_target_properties(${target}
-      PROPERTIES LINK_OPTIONS
-      "-fopenmp;--offload-arch=native"
-      )
-  endif()
-endfunction()
-
 function(add_flang_unittest test_dirname)
   add_unittest(FlangUnitTests ${test_dirname} ${ARGN})
-  add_flang_unittest_offload_properties(${test_dirname})
 endfunction()
 
 if (CXX_SUPPORTS_SUGGEST_OVERRIDE_FLAG)
@@ -67,13 +35,8 @@ function(add_flang_nongtest_unittest test_name)
   if(NOT ARG_SLOW_TEST)
     add_dependencies(FlangUnitTests ${test_name}${suffix})
   endif()
-
-  add_flang_unittest_offload_properties(${test_name}${suffix})
 endfunction()
 
 add_subdirectory(Optimizer)
-add_subdirectory(Common)
-add_subdirectory(Decimal)
 add_subdirectory(Evaluate)
-add_subdirectory(Runtime)
 add_subdirectory(Frontend)
diff --git a/flang/unittests/Common/CMakeLists.txt b/flang/unittests/Common/CMakeLists.txt
deleted file mode 100644
index bda02ed29a5efa..00000000000000
--- a/flang/unittests/Common/CMakeLists.txt
+++ /dev/null
@@ -1,3 +0,0 @@
-add_flang_unittest(FlangCommonTests
-  FastIntSetTest.cpp
-)
diff --git a/flang/unittests/Decimal/CMakeLists.txt b/flang/unittests/Decimal/CMakeLists.txt
deleted file mode 100644
index d301a9d3628c56..00000000000000
--- a/flang/unittests/Decimal/CMakeLists.txt
+++ /dev/null
@@ -1,10 +0,0 @@
-set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
-add_flang_nongtest_unittest(quick-sanity-test
-  FortranDecimal
-)
-
-# This test is not run by default as it takes a long time to execute.
-add_flang_nongtest_unittest(thorough-test
-  SLOW_TEST
-  FortranDecimal
-)
diff --git a/flang/unittests/Evaluate/CMakeLists.txt b/flang/unittests/Evaluate/CMakeLists.txt
index 52eb385f4763fb..a7f763d7b17d85 100644
--- a/flang/unittests/Evaluate/CMakeLists.txt
+++ b/flang/unittests/Evaluate/CMakeLists.txt
@@ -1,7 +1,7 @@
 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
 add_library(FortranEvaluateTesting
-  testing.cpp
-  fp-testing.cpp
+  ${FORTRANRUNTIME_SOURCE_DIR}/lib/Testing/testing.cpp
+  ${FORTRANRUNTIME_SOURCE_DIR}/lib/Testing/fp-testing.cpp
 )
 set_target_properties(FortranEvaluateTesting PROPERTIES FOLDER "Flang/Tests")
 if (LLVM_LINK_LLVM_DYLIB)
@@ -40,13 +40,12 @@ add_flang_nongtest_unittest(integer
 )
 
 add_flang_nongtest_unittest(intrinsics
+  FortranSupport
   FortranCommon
   FortranEvaluateTesting
   FortranEvaluate
-  FortranDecimal
   FortranSemantics
   FortranParser
-  FortranRuntime
 )
 
 add_flang_nongtest_unittest(logical
@@ -64,25 +63,12 @@ set(LLVM_REQUIRES_RTTI ON)
 add_flang_nongtest_unittest(real
   FortranEvaluateTesting
   FortranEvaluate
-  FortranDecimal
+  FortranCommon
+  FortranSupport
   FortranSemantics
 )
 llvm_update_compile_flags(real.test)
 
-add_flang_nongtest_unittest(reshape
-  FortranEvaluateTesting
-  FortranSemantics
-  FortranEvaluate
-  FortranRuntime
-)
-
-add_flang_nongtest_unittest(ISO-Fortran-binding
-  FortranEvaluateTesting
-  FortranEvaluate
-  FortranSemantics
-  FortranRuntime
-)
-
 add_flang_nongtest_unittest(folding
   FortranCommon
   FortranEvaluateTesting
diff --git a/flang/unittests/Evaluate/bit-population-count.cpp b/flang/unittests/Evaluate/bit-population-count.cpp
index 24e721c14f94a7..0c9529a92e5724 100644
--- a/flang/unittests/Evaluate/bit-population-count.cpp
+++ b/flang/unittests/Evaluate/bit-population-count.cpp
@@ -1,5 +1,5 @@
 #include "flang/Common/bit-population-count.h"
-#include "testing.h"
+#include "flang/Testing/testing.h"
 
 using Fortran::common::BitPopulationCount;
 using Fortran::common::Parity;
diff --git a/flang/unittests/Evaluate/expression.cpp b/flang/unittests/Evaluate/expression.cpp
index f03a6bc2a4e23c..6349997bafee48 100644
--- a/flang/unittests/Evaluate/expression.cpp
+++ b/flang/unittests/Evaluate/expression.cpp
@@ -1,5 +1,5 @@
 #include "flang/Evaluate/expression.h"
-#include "testing.h"
+#include "flang/Testing/testing.h"
 #include "flang/Evaluate/fold.h"
 #include "flang/Evaluate/intrinsics.h"
 #include "flang/Evaluate/target.h"
diff --git a/flang/unittests/Evaluate/folding.cpp b/flang/unittests/Evaluate/folding.cpp
index 4e8ff9754e4ccb..35df702ff20ea6 100644
--- a/flang/unittests/Evaluate/folding.cpp
+++ b/flang/unittests/Evaluate/folding.cpp
@@ -1,4 +1,4 @@
-#include "testing.h"
+#include "flang/Testing/testing.h"
 #include "../../lib/Evaluate/host.h"
 #include "flang/Evaluate/call.h"
 #include "flang/Evaluate/expression.h"
diff --git a/flang/unittests/Evaluate/integer.cpp b/flang/unittests/Evaluate/integer.cpp
index 3eabb2434cce60..5ab22cc6443a7b 100644
--- a/flang/unittests/Evaluate/integer.cpp
+++ b/flang/unittests/Evaluate/integer.cpp
@@ -1,5 +1,5 @@
 #include "flang/Evaluate/integer.h"
-#include "testing.h"
+#include "flang/Testing/testing.h"
 #include <cstdio>
 #include <string>
 
diff --git a/flang/unittests/Evaluate/intrinsics.cpp b/flang/unittests/Evaluate/intrinsics.cpp
index 86c471d2c62950..0baf01a4cb1b7e 100644
--- a/flang/unittests/Evaluate/intrinsics.cpp
+++ b/flang/unittests/Evaluate/intrinsics.cpp
@@ -1,5 +1,5 @@
 #include "flang/Evaluate/intrinsics.h"
-#include "testing.h"
+#include "flang/Testing/testing.h"
 #include "flang/Evaluate/common.h"
 #include "flang/Evaluate/expression.h"
 #include "flang/Evaluate/target.h"
diff --git a/flang/unittests/Evaluate/leading-zero-bit-count.cpp b/flang/unittests/Evaluate/leading-zero-bit-count.cpp
index 968946b69f27ea..25e2664e76df04 100644
--- a/flang/unittests/Evaluate/leading-zero-bit-count.cpp
+++ b/flang/unittests/Evaluate/leading-zero-bit-count.cpp
@@ -1,5 +1,5 @@
 #include "flang/Common/leading-zero-bit-count.h"
-#include "testing.h"
+#include "flang/Testing/testing.h"
 
 using Fortran::common::LeadingZeroBitCount;
 
diff --git a/flang/unittests/Evaluate/logical.cpp b/flang/unittests/Evaluate/logical.cpp
index d79aff84487123..ee568371eab86c 100644
--- a/flang/unittests/Evaluate/logical.cpp
+++ b/flang/unittests/Evaluate/logical.cpp
@@ -1,4 +1,4 @@
-#include "testing.h"
+#include "flang/Testing/testing.h"
 #include "flang/Evaluate/type.h"
 #include <cstdio>
 
diff --git a/flang/unittests/Evaluate/real.cpp b/flang/unittests/Evaluate/real.cpp
index ccbaf81f054cb5..ab1a178df22312 100644
--- a/flang/unittests/Evaluate/real.cpp
+++ b/flang/unittests/Evaluate/real.cpp
@@ -1,5 +1,5 @@
-#include "fp-testing.h"
-#include "testing.h"
+#include "flang/Testing/fp-testing.h"
+#include "flang/Testing/testing.h"
 #include "flang/Evaluate/type.h"
 #include "llvm/Support/raw_ostream.h"
 #include <cmath>
diff --git a/flang/unittests/Evaluate/uint128.cpp b/flang/unittests/Evaluate/uint128.cpp
index f05c1c96a7e8b0..0b749abe1c080a 100644
--- a/flang/unittests/Evaluate/uint128.cpp
+++ b/flang/unittests/Evaluate/uint128.cpp
@@ -1,6 +1,6 @@
 #define AVOID_NATIVE_UINT128_T 1
 #include "flang/Common/uint128.h"
-#include "testing.h"
+#include "flang/Testing/testing.h"
 #include "llvm/Support/raw_ostream.h"
 #include <cinttypes>
 
diff --git a/flang/unittests/Runtime/CUDA/CMakeLists.txt b/flang/unittests/Runtime/CUDA/CMakeLists.txt
deleted file mode 100644
index ed0caece3d15db..00000000000000
--- a/flang/unittests/Runtime/CUDA/CMakeLists.txt
+++ /dev/null
@@ -1,15 +0,0 @@
-if (FLANG_CUF_RUNTIME)
-
-add_flang_unittest(FlangCufRuntimeTests
-  AllocatorCUF.cpp
-)
-
-target_link_libraries(FlangCufRuntimeTests
-  PRIVATE
-  CufRuntime_cuda_${CUDAToolkit_VERSION_MAJOR}
-  FortranRuntime
-)
-
-target_include_directories(FlangCufRuntimeTests PRIVATE ${CUDAToolkit_INCLUDE_DIRS})
-
-endif()
diff --git a/lld/COFF/MinGW.cpp b/lld/COFF/MinGW.cpp
index 29c01da9e28f6d..e4e6a3bb52410f 100644
--- a/lld/COFF/MinGW.cpp
+++ b/lld/COFF/MinGW.cpp
@@ -51,7 +51,11 @@ AutoExporter::AutoExporter(
       "libc++",
       "libc++abi",
       "libFortranRuntime",
-      "libFortranDecimal",
+      "libFortranFloat128Math",
+      "libFortranRuntime.static",
+      "libFortranRuntime.dynamic",
+      "libFortranRuntime.static_dbg",
+      "libFortranRuntime.dynamic_dbg",
       "libunwind",
       "libmsvcrt",
       "libucrtbase",
diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt
index c637febce1c1fe..70f6f50ee5e11a 100644
--- a/llvm/CMakeLists.txt
+++ b/llvm/CMakeLists.txt
@@ -149,7 +149,7 @@ endif()
 # As we migrate runtimes to using the bootstrapping build, the set of default runtimes
 # should grow as we remove those runtimes from LLVM_ENABLE_PROJECTS above.
 set(LLVM_DEFAULT_RUNTIMES "libcxx;libcxxabi;libunwind")
-set(LLVM_SUPPORTED_RUNTIMES "libc;libunwind;libcxxabi;pstl;libcxx;compiler-rt;openmp;llvm-libgcc;offload")
+set(LLVM_SUPPORTED_RUNTIMES "libc;libunwind;libcxxabi;pstl;libcxx;compiler-rt;openmp;llvm-libgcc;offload;FortranRuntime")
 set(LLVM_ENABLE_RUNTIMES "" CACHE STRING
   "Semicolon-separated list of runtimes to build, or \"all\" (${LLVM_DEFAULT_RUNTIMES}). Supported runtimes are ${LLVM_SUPPORTED_RUNTIMES}.")
 if(LLVM_ENABLE_RUNTIMES STREQUAL "all")
diff --git a/llvm/cmake/modules/LLVMExternalProjectUtils.cmake b/llvm/cmake/modules/LLVMExternalProjectUtils.cmake
index f7e1165bc4b947..f49ce19b3f845c 100644
--- a/llvm/cmake/modules/LLVMExternalProjectUtils.cmake
+++ b/llvm/cmake/modules/LLVMExternalProjectUtils.cmake
@@ -34,6 +34,8 @@ endfunction()
 
 
 # llvm_ExternalProject_Add(name source_dir ...
+#   ENABLE_FORTRAN
+#     External project requires the Flang compiler
 #   USE_TOOLCHAIN
 #     Use just-built tools (see TOOLCHAIN_TOOLS)
 #   EXCLUDE_FROM_ALL
@@ -61,7 +63,7 @@ endfunction()
 #   )
 function(llvm_ExternalProject_Add name source_dir)
   cmake_parse_arguments(ARG
-    "USE_TOOLCHAIN;EXCLUDE_FROM_ALL;NO_INSTALL;ALWAYS_CLEAN"
+    "ENABLE_FORTRAN;USE_TOOLCHAIN;EXCLUDE_FROM_ALL;NO_INSTALL;ALWAYS_CLEAN"
     "SOURCE_DIR;FOLDER"
     "CMAKE_ARGS;TOOLCHAIN_TOOLS;RUNTIME_LIBRARIES;DEPENDS;EXTRA_TARGETS;PASSTHROUGH_PREFIXES;STRIP_TOOL;TARGET_TRIPLE"
     ${ARGN})
@@ -89,6 +91,9 @@ function(llvm_ExternalProject_Add name source_dir)
 
   if(NOT ARG_TOOLCHAIN_TOOLS)
     set(ARG_TOOLCHAIN_TOOLS clang)
+    if (ARG_ENABLE_FORTRAN)
+      list(APPEND ARG_TOOLCHAIN_TOOLS flang-new)
+    endif ()
     # AIX 64-bit XCOFF and big AR format is not yet supported in some of these tools.
     if(NOT _cmake_system_name STREQUAL AIX)
       list(APPEND ARG_TOOLCHAIN_TOOLS lld llvm-ar llvm-ranlib llvm-nm llvm-objdump)
@@ -139,6 +144,10 @@ function(llvm_ExternalProject_Add name source_dir)
     set(CLANG_IN_TOOLCHAIN On)
   endif()
 
+  if(flang-new IN_LIST TOOLCHAIN_TOOLS)
+    set(FLANG_IN_TOOLCHAIN On)
+  endif()
+
   if(RUNTIME_LIBRARIES AND CLANG_IN_TOOLCHAIN)
     list(APPEND TOOLCHAIN_BINS ${RUNTIME_LIBRARIES})
   endif()
@@ -221,6 +230,9 @@ function(llvm_ExternalProject_Add name source_dir)
                           -DCMAKE_ASM_COMPILER=${LLVM_RUNTIME_OUTPUT_INTDIR}/clang${CMAKE_EXECUTABLE_SUFFIX})
       endif()
     endif()
+    if(FLANG_IN_TOOLCHAIN)
+      list(APPEND compiler_args -DCMAKE_Fortran_COMPILER=${LLVM_RUNTIME_OUTPUT_INTDIR}/flang-new${CMAKE_EXECUTABLE_SUFFIX})
+    endif()
     if(lld IN_LIST TOOLCHAIN_TOOLS)
       if(is_msvc_target)
         list(APPEND compiler_args -DCMAKE_LINKER=${LLVM_RUNTIME_OUTPUT_INTDIR}/lld-link${CMAKE_EXECUTABLE_SUFFIX})
@@ -304,6 +316,7 @@ function(llvm_ExternalProject_Add name source_dir)
     set(compiler_args -DCMAKE_ASM_COMPILER=${CMAKE_ASM_COMPILER}
                       -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
                       -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
+                      -DCMAKE_Fortran_COMPILER=${CMAKE_Fortran_COMPILER}
                       -DCMAKE_LINKER=${CMAKE_LINKER}
                       -DCMAKE_AR=${CMAKE_AR}
                       -DCMAKE_RANLIB=${CMAKE_RANLIB}
@@ -353,6 +366,7 @@ function(llvm_ExternalProject_Add name source_dir)
   if(ARG_TARGET_TRIPLE)
     list(APPEND compiler_args -DCMAKE_C_COMPILER_TARGET=${ARG_TARGET_TRIPLE})
     list(APPEND compiler_args -DCMAKE_CXX_COMPILER_TARGET=${ARG_TARGET_TRIPLE})
+    list(APPEND compiler_args -DCMAKE_Fortran_COMPILER_TARGET=${ARG_TARGET_TRIPLE})
     list(APPEND compiler_args -DCMAKE_ASM_COMPILER_TARGET=${ARG_TARGET_TRIPLE})
   endif()
 
diff --git a/llvm/projects/CMakeLists.txt b/llvm/projects/CMakeLists.txt
index 08f2fa522420b0..fab28c9df6d384 100644
--- a/llvm/projects/CMakeLists.txt
+++ b/llvm/projects/CMakeLists.txt
@@ -11,7 +11,8 @@ foreach(entry ${entries})
        (NOT ${entry} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR}/libunwind) AND
        (NOT ${entry} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR}/test-suite) AND
        (NOT ${entry} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR}/openmp) AND
-       (NOT ${entry} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR}/cross-project-tests))
+       (NOT ${entry} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR}/cross-project-tests) AND
+       (NOT ${entry} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR}/FortranRuntime))
       get_filename_component(entry_name "${entry}" NAME)
       add_llvm_external_project(${entry_name})
     endif()
@@ -37,6 +38,8 @@ if(${LLVM_BUILD_RUNTIME})
   if(NOT LLVM_BUILD_EXTERNAL_COMPILER_RT)
     add_llvm_external_project(compiler-rt)
   endif()
+
+  add_llvm_external_project(FortranRuntime)
 endif()
 
 add_llvm_external_project(dragonegg)
diff --git a/llvm/runtimes/CMakeLists.txt b/llvm/runtimes/CMakeLists.txt
index 187c44fb9d04d2..e4389b120f49df 100644
--- a/llvm/runtimes/CMakeLists.txt
+++ b/llvm/runtimes/CMakeLists.txt
@@ -96,6 +96,7 @@ function(builtin_default_target compiler_rt_path)
                                       -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=${LLVM_ENABLE_PER_TARGET_RUNTIME_DIR}
                                       -DLLVM_CMAKE_DIR=${CMAKE_BINARY_DIR}
                                       -DCMAKE_C_COMPILER_WORKS=ON
+                                      -DCMAKE_Fortran_COMPILER_WORKS=ON
                                       -DCMAKE_ASM_COMPILER_WORKS=ON
                                       ${COMMON_CMAKE_ARGS}
                                       ${BUILTINS_CMAKE_ARGS}
@@ -136,6 +137,7 @@ function(builtin_register_target compiler_rt_path name)
                                       -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=ON
                                       -DLLVM_CMAKE_DIR=${CMAKE_BINARY_DIR}
                                       -DCMAKE_C_COMPILER_WORKS=ON
+                                      -DCMAKE_Fortran_COMPILER_WORKS=ON
                                       -DCMAKE_ASM_COMPILER_WORKS=ON
                                       -DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON
                                       ${COMMON_CMAKE_ARGS}
@@ -261,6 +263,7 @@ function(runtime_default_target)
   llvm_ExternalProject_Add(runtimes
                            ${CMAKE_CURRENT_SOURCE_DIR}/../../runtimes
                            DEPENDS ${ARG_DEPENDS}
+                           ${enable_fortran}
                            # Builtins were built separately above
                            CMAKE_ARGS -DCOMPILER_RT_BUILD_BUILTINS=Off
                                       -DLLVM_INCLUDE_TESTS=${LLVM_INCLUDE_TESTS}
@@ -270,6 +273,7 @@ function(runtime_default_target)
                                       -DLLVM_BUILD_TOOLS=${LLVM_BUILD_TOOLS}
                                       -DCMAKE_C_COMPILER_WORKS=ON
                                       -DCMAKE_CXX_COMPILER_WORKS=ON
+                                      -DCMAKE_Fortran_COMPILER_WORKS=ON
                                       -DCMAKE_ASM_COMPILER_WORKS=ON
                                       ${COMMON_CMAKE_ARGS}
                                       ${RUNTIMES_CMAKE_ARGS}
@@ -396,6 +400,7 @@ function(runtime_register_target name)
   llvm_ExternalProject_Add(runtimes-${name}
                            ${CMAKE_CURRENT_SOURCE_DIR}/../../runtimes
                            DEPENDS ${ARG_DEPENDS}
+                           ${enable_fortran}
                            # Builtins were built separately above
                            CMAKE_ARGS -DCOMPILER_RT_BUILD_BUILTINS=OFF
                                       -DLLVM_INCLUDE_TESTS=${LLVM_INCLUDE_TESTS}
@@ -403,6 +408,7 @@ function(runtime_register_target name)
                                       -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=${LLVM_ENABLE_PER_TARGET_RUNTIME_DIR}
                                       -DCMAKE_C_COMPILER_WORKS=ON
                                       -DCMAKE_CXX_COMPILER_WORKS=ON
+                                      -DCMAKE_Fortran_COMPILER_WORKS=ON
                                       -DCMAKE_ASM_COMPILER_WORKS=ON
                                       -DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON
                                       -DLLVM_RUNTIMES_TARGET=${name}
@@ -462,10 +468,12 @@ if(build_runtimes)
   # together in a single CMake invocation.
   set(extra_deps "")
   set(extra_cmake_args "")
+  set(enable_fortran "")
 
   if(LLVM_INCLUDE_TESTS)
     foreach(dep FileCheck
                 clang
+                flang-new
                 count
                 lld
                 lli
@@ -502,18 +510,17 @@ if(build_runtimes)
     list(APPEND extra_cmake_args "-DCMAKE_PROGRAM_PATH=${CMAKE_PROGRAM_PATH}")
   endif()
 
+  # FIXME: Go away
   if("openmp" IN_LIST LLVM_ENABLE_RUNTIMES)
-    if (${LLVM_TOOL_FLANG_BUILD})
-      message(STATUS "Configuring build of omp_lib.mod and omp_lib_kinds.mod via flang-new")
-      set(LIBOMP_FORTRAN_MODULES_COMPILER "${CMAKE_BINARY_DIR}/bin/flang-new")
-      set(LIBOMP_MODULES_INSTALL_PATH "${CMAKE_INSTALL_INCLUDEDIR}/flang")
-      # TODO: This is a workaround until flang becomes a first-class project
-      # in llvm/CMakeList.txt.  Until then, this line ensures that flang-new is
-      # built before "openmp" is built as a runtime project.  Besides "flang-new"
-      # to build the compiler, we also need to add "module_files" to make sure
-      # that all .mod files are also properly build.
-      list(APPEND extra_deps "flang-new" "module_files")
-    endif()
+    #if (LLVM_TOOL_FLANG_BUILD AND "FortranRuntime" IN_LIST LLVM_ENABLE_PROJECTS)
+    #  message(STATUS "Configuring build of omp_lib.mod and omp_lib_kinds.mod via flang-new")
+    #  set(LIBOMP_FORTRAN_MODULES_COMPILER "${CMAKE_BINARY_DIR}/bin/flang-new${CMAKE_EXECUTABLE_SUFFIX}")
+    #  #TODO: set(LIBOMP_MODULES_INSTALL_PATH "${CMAKE_INSTALL_INCLUDEDIR}/flang")
+    #  list(APPEND extra_deps "flang-new")
+    #endif()
+    if (LLVM_TOOL_FLANG_BUILD AND "FortranRuntime" IN_LIST LLVM_ENABLE_PROJECTS)
+      set(enable_fortran ENABLE_FORTRAN)
+    endif ()
     foreach(dep opt llvm-link llvm-extract clang clang-offload-packager)
       if(TARGET ${dep})
         list(APPEND extra_deps ${dep})
@@ -563,6 +570,9 @@ if(build_runtimes)
   if(LLVM_LIBC_FULL_BUILD)
     list(APPEND extra_cmake_args "-DLLVM_LIBC_FULL_BUILD=ON")
   endif()
+  if("FortranRuntime" IN_LIST LLVM_ENABLE_RUNTIMES)
+    set(enable_fortran ENABLE_FORTRAN)
+  endif ()
 
   if(NOT LLVM_RUNTIME_TARGETS)
     runtime_default_target(
diff --git a/runtimes/CMakeLists.txt b/runtimes/CMakeLists.txt
index 830165c799c2ab..d77b4da6e00e34 100644
--- a/runtimes/CMakeLists.txt
+++ b/runtimes/CMakeLists.txt
@@ -23,7 +23,7 @@ list(INSERT CMAKE_MODULE_PATH 0
 
 # We order libraries to mirror roughly how they are layered, except that compiler-rt can depend
 # on libc++, so we put it after.
-set(LLVM_DEFAULT_RUNTIMES "libc;libunwind;libcxxabi;pstl;libcxx;compiler-rt;openmp;offload")
+set(LLVM_DEFAULT_RUNTIMES "libc;libunwind;libcxxabi;pstl;libcxx;compiler-rt;openmp;offload;FortranRuntime")
 set(LLVM_SUPPORTED_RUNTIMES "${LLVM_DEFAULT_RUNTIMES};llvm-libgcc")
 set(LLVM_ENABLE_RUNTIMES "" CACHE STRING
   "Semicolon-separated list of runtimes to build, or \"all\" (${LLVM_DEFAULT_RUNTIMES}). Supported runtimes are ${LLVM_SUPPORTED_RUNTIMES}.")
@@ -49,6 +49,7 @@ function(runtime_register_component name)
   set_property(GLOBAL APPEND PROPERTY SUB_COMPONENTS ${name})
 endfunction()
 
+message("LLVM_BINARY_DIR: ${LLVM_BINARY_DIR}")
 find_package(LLVM PATHS "${LLVM_BINARY_DIR}" NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH)
 find_package(Clang PATHS "${LLVM_BINARY_DIR}" NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH)
 

>From 70ef83a93bfdff7fd4eb5091ecb8b5ca8307b62b Mon Sep 17 00:00:00 2001
From: Michael Kruse <llvm-project at meinersbur.de>
Date: Fri, 27 Sep 2024 12:40:40 +0200
Subject: [PATCH 2/6] [Flang] Split common headers

---
 flang/include/flang/Common/Fortran-consts.h  | 44 ++++++++++++++++++++
 flang/include/flang/Common/Fortran.h         | 26 +-----------
 flang/include/flang/Common/format.h          |  2 +-
 flang/include/flang/Common/target-rounding.h | 37 ++++++++++++++++
 flang/include/flang/Evaluate/common.h        |  8 ++--
 flang/include/flang/Evaluate/target.h        | 15 +------
 flang/include/flang/Runtime/cpp-type.h       |  2 +-
 flang/include/flang/Runtime/type-code.h      |  2 +-
 flang/runtime/format.h                       |  2 +-
 flang/runtime/non-tbp-dio.h                  |  3 +-
 flang/runtime/type-info.h                    |  4 +-
 flang/unittests/Evaluate/fp-testing.cpp      |  2 +-
 flang/unittests/Evaluate/fp-testing.h        |  6 +--
 flang/unittests/Runtime/Complex.cpp          |  2 +-
 14 files changed, 100 insertions(+), 55 deletions(-)
 create mode 100644 flang/include/flang/Common/Fortran-consts.h
 create mode 100644 flang/include/flang/Common/target-rounding.h

diff --git a/flang/include/flang/Common/Fortran-consts.h b/flang/include/flang/Common/Fortran-consts.h
new file mode 100644
index 00000000000000..3d4377dd5a076c
--- /dev/null
+++ b/flang/include/flang/Common/Fortran-consts.h
@@ -0,0 +1,44 @@
+//===-- include/flang/Common/Fortran-consts.h -------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef FORTRAN_COMMON_FORTRAN_CONSTS_H_
+#define FORTRAN_COMMON_FORTRAN_CONSTS_H_
+
+#include "flang/Common/enum-class.h"
+#include <cstdint>
+
+namespace Fortran::common {
+
+// Fortran has five kinds of intrinsic data types, plus the derived types.
+ENUM_CLASS(TypeCategory, Integer, Real, Complex, Character, Logical, Derived)
+ENUM_CLASS(VectorElementCategory, Integer, Unsigned, Real)
+
+ENUM_CLASS(IoStmtKind, None, Backspace, Close, Endfile, Flush, Inquire, Open,
+    Print, Read, Rewind, Wait, Write)
+
+// Defined I/O variants
+ENUM_CLASS(
+    DefinedIo, ReadFormatted, ReadUnformatted, WriteFormatted, WriteUnformatted)
+
+// Fortran arrays may have up to 15 dimensions (See Fortran 2018 section 5.4.6).
+static constexpr int maxRank{15};
+
+// Floating-point rounding modes; these are packed into a byte to save
+// room in the runtime's format processing context structure.  These
+// enumerators are defined with the corresponding values returned from
+// llvm.get.rounding.
+enum class RoundingMode : std::uint8_t {
+  ToZero, // ROUND=ZERO, RZ - truncation
+  TiesToEven, // ROUND=NEAREST, RN - default IEEE rounding
+  Up, // ROUND=UP, RU
+  Down, // ROUND=DOWN, RD
+  TiesAwayFromZero, // ROUND=COMPATIBLE, RC - ties round away from zero
+};
+
+} // namespace Fortran::common
+#endif // FORTRAN_COMMON_FORTRAN_CONSTS_H_
diff --git a/flang/include/flang/Common/Fortran.h b/flang/include/flang/Common/Fortran.h
index 5b2ed43a8f99c0..7c8d788dd563d9 100644
--- a/flang/include/flang/Common/Fortran.h
+++ b/flang/include/flang/Common/Fortran.h
@@ -12,6 +12,7 @@
 // Fortran language concepts that are used in many phases are defined
 // once here to avoid redundancy and needless translation.
 
+#include "flang/Common/Fortran-consts.h"
 #include "enum-set.h"
 #include "idioms.h"
 #include <cinttypes>
@@ -21,10 +22,6 @@
 namespace Fortran::common {
 class LanguageFeatureControl;
 
-// Fortran has five kinds of intrinsic data types, plus the derived types.
-ENUM_CLASS(TypeCategory, Integer, Real, Complex, Character, Logical, Derived)
-ENUM_CLASS(VectorElementCategory, Integer, Unsigned, Real)
-
 constexpr bool IsNumericTypeCategory(TypeCategory category) {
   return category == TypeCategory::Integer || category == TypeCategory::Real ||
       category == TypeCategory::Complex;
@@ -47,9 +44,6 @@ const char *AsFortran(RelationalOperator);
 
 ENUM_CLASS(Intent, Default, In, Out, InOut)
 
-ENUM_CLASS(IoStmtKind, None, Backspace, Close, Endfile, Flush, Inquire, Open,
-    Print, Read, Rewind, Wait, Write)
-
 // Union of specifiers for all I/O statements.
 ENUM_CLASS(IoSpecKind, Access, Action, Advance, Asynchronous, Blank, Decimal,
     Delim, Direct, Encoding, End, Eor, Err, Exist, File, Fmt, Form, Formatted,
@@ -61,29 +55,11 @@ ENUM_CLASS(IoSpecKind, Access, Action, Advance, Asynchronous, Blank, Decimal,
     Dispose, // nonstandard
 )
 
-// Defined I/O variants
-ENUM_CLASS(
-    DefinedIo, ReadFormatted, ReadUnformatted, WriteFormatted, WriteUnformatted)
 const char *AsFortran(DefinedIo);
 
-// Floating-point rounding modes; these are packed into a byte to save
-// room in the runtime's format processing context structure.  These
-// enumerators are defined with the corresponding values returned from
-// llvm.get.rounding.
-enum class RoundingMode : std::uint8_t {
-  ToZero, // ROUND=ZERO, RZ - truncation
-  TiesToEven, // ROUND=NEAREST, RN - default IEEE rounding
-  Up, // ROUND=UP, RU
-  Down, // ROUND=DOWN, RD
-  TiesAwayFromZero, // ROUND=COMPATIBLE, RC - ties round away from zero
-};
-
 // Fortran label. Must be in [1..99999].
 using Label = std::uint64_t;
 
-// Fortran arrays may have up to 15 dimensions (See Fortran 2018 section 5.4.6).
-static constexpr int maxRank{15};
-
 // CUDA subprogram attribute combinations
 ENUM_CLASS(CUDASubprogramAttrs, Host, Device, HostDevice, Global, Grid_Global)
 
diff --git a/flang/include/flang/Common/format.h b/flang/include/flang/Common/format.h
index 2374ff6983cf41..138e84b72b733d 100644
--- a/flang/include/flang/Common/format.h
+++ b/flang/include/flang/Common/format.h
@@ -10,7 +10,7 @@
 #define FORTRAN_COMMON_FORMAT_H_
 
 #include "enum-set.h"
-#include "flang/Common/Fortran.h"
+#include "flang/Common/Fortran-consts.h"
 #include <cstring>
 
 // Define a FormatValidator class template to validate a format expression
diff --git a/flang/include/flang/Common/target-rounding.h b/flang/include/flang/Common/target-rounding.h
new file mode 100644
index 00000000000000..e31920f5f6343e
--- /dev/null
+++ b/flang/include/flang/Common/target-rounding.h
@@ -0,0 +1,37 @@
+//===-- include/flang/Common/target-rounding.h ------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef FORTRAN_COMMON_TARGET_ROUNDING_H_
+#define FORTRAN_COMMON_TARGET_ROUNDING_H_
+
+#include "flang/Common/Fortran-consts.h"
+#include "flang/Common/enum-set.h"
+
+namespace Fortran::common {
+
+// Floating-point rounding control
+struct Rounding {
+  common::RoundingMode mode{common::RoundingMode::TiesToEven};
+  // When set, emulate status flag behavior peculiar to x86
+  // (viz., fail to set the Underflow flag when an inexact product of a
+  // multiplication is rounded up to a normal number from a subnormal
+  // in some rounding modes)
+#if __x86_64__ || __riscv || __loongarch__
+  bool x86CompatibleBehavior{true};
+#else
+  bool x86CompatibleBehavior{false};
+#endif
+};
+
+// These are ordered like the bits in a common fenv.h header file.
+ENUM_CLASS(RealFlag, InvalidArgument, Denorm, DivideByZero, Overflow, Underflow,
+    Inexact)
+using RealFlags = common::EnumSet<RealFlag, RealFlag_enumSize>;
+
+} // namespace Fortran::common
+#endif // FORTRAN_COMMON_TARGET_ROUNDING_H_
diff --git a/flang/include/flang/Evaluate/common.h b/flang/include/flang/Evaluate/common.h
index d493e5fe044173..915e95169c7f81 100644
--- a/flang/include/flang/Evaluate/common.h
+++ b/flang/include/flang/Evaluate/common.h
@@ -16,6 +16,7 @@
 #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 <cinttypes>
@@ -32,6 +33,8 @@ class IntrinsicProcTable;
 class TargetCharacteristics;
 
 using common::ConstantSubscript;
+using common::RealFlag;
+using common::RealFlags;
 using common::RelationalOperator;
 
 // Integers are always ordered; reals may not be.
@@ -128,11 +131,6 @@ static constexpr bool Satisfies(RelationalOperator op, Relation relation) {
   return false; // silence g++ warning
 }
 
-// These are ordered like the bits in a common fenv.h header file.
-ENUM_CLASS(RealFlag, InvalidArgument, Denorm, DivideByZero, Overflow, Underflow,
-    Inexact)
-using RealFlags = common::EnumSet<RealFlag, RealFlag_enumSize>;
-
 template <typename A> struct ValueWithRealFlags {
   A AccumulateFlags(RealFlags &f) {
     f |= flags;
diff --git a/flang/include/flang/Evaluate/target.h b/flang/include/flang/Evaluate/target.h
index d076fcbf083078..1950a4cb6bfc76 100644
--- a/flang/include/flang/Evaluate/target.h
+++ b/flang/include/flang/Evaluate/target.h
@@ -15,24 +15,13 @@
 #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 <cstdint>
 
 namespace Fortran::evaluate {
 
-// Floating-point rounding control
-struct Rounding {
-  common::RoundingMode mode{common::RoundingMode::TiesToEven};
-  // When set, emulate status flag behavior peculiar to x86
-  // (viz., fail to set the Underflow flag when an inexact product of a
-  // multiplication is rounded up to a normal number from a subnormal
-  // in some rounding modes)
-#if __x86_64__ || __riscv || __loongarch__
-  bool x86CompatibleBehavior{true};
-#else
-  bool x86CompatibleBehavior{false};
-#endif
-};
+using common::Rounding;
 
 ENUM_CLASS(IeeeFeature, Denormal, Divide, Flags, Halting, Inf, Io, NaN,
     Rounding, Sqrt, Standard, Subnormal, UnderflowControl)
diff --git a/flang/include/flang/Runtime/cpp-type.h b/flang/include/flang/Runtime/cpp-type.h
index fe21dd544cf7d8..27b43de7d0f0f6 100644
--- a/flang/include/flang/Runtime/cpp-type.h
+++ b/flang/include/flang/Runtime/cpp-type.h
@@ -11,7 +11,7 @@
 #ifndef FORTRAN_RUNTIME_CPP_TYPE_H_
 #define FORTRAN_RUNTIME_CPP_TYPE_H_
 
-#include "flang/Common/Fortran.h"
+#include "flang/Common/Fortran-consts.h"
 #include "flang/Common/float128.h"
 #include "flang/Common/uint128.h"
 #include <complex>
diff --git a/flang/include/flang/Runtime/type-code.h b/flang/include/flang/Runtime/type-code.h
index 8e7314e0af1efc..dd3a9f2690ee74 100644
--- a/flang/include/flang/Runtime/type-code.h
+++ b/flang/include/flang/Runtime/type-code.h
@@ -9,7 +9,7 @@
 #ifndef FORTRAN_RUNTIME_TYPE_CODE_H_
 #define FORTRAN_RUNTIME_TYPE_CODE_H_
 
-#include "flang/Common/Fortran.h"
+#include "flang/Common/Fortran-consts.h"
 #include "flang/Common/optional.h"
 #include "flang/ISO_Fortran_binding_wrapper.h"
 #include <utility>
diff --git a/flang/runtime/format.h b/flang/runtime/format.h
index 5329f2482d3e46..815bf70685e647 100644
--- a/flang/runtime/format.h
+++ b/flang/runtime/format.h
@@ -13,7 +13,7 @@
 
 #include "environment.h"
 #include "io-error.h"
-#include "flang/Common/Fortran.h"
+#include "flang/Common/Fortran-consts.h"
 #include "flang/Common/optional.h"
 #include "flang/Decimal/decimal.h"
 #include "flang/Runtime/freestanding-tools.h"
diff --git a/flang/runtime/non-tbp-dio.h b/flang/runtime/non-tbp-dio.h
index 05038a264ed992..8429d790fea57a 100644
--- a/flang/runtime/non-tbp-dio.h
+++ b/flang/runtime/non-tbp-dio.h
@@ -22,7 +22,8 @@
 #ifndef FORTRAN_RUNTIME_NON_TBP_DIO_H_
 #define FORTRAN_RUNTIME_NON_TBP_DIO_H_
 
-#include "flang/Common/Fortran.h"
+#include "flang/Common/Fortran-consts.h"
+#include "flang/Common/api-attrs.h"
 #include <cstddef>
 
 namespace Fortran::runtime::typeInfo {
diff --git a/flang/runtime/type-info.h b/flang/runtime/type-info.h
index c3f3595e32ef28..3ccab0ff73ed20 100644
--- a/flang/runtime/type-info.h
+++ b/flang/runtime/type-info.h
@@ -12,11 +12,11 @@
 // A C++ perspective of the derived type description schemata in
 // flang/module/__fortran_type_info.f90.
 
-#include "terminator.h"
-#include "flang/Common/Fortran.h"
+#include "flang/Common/Fortran-consts.h"
 #include "flang/Common/bit-population-count.h"
 #include "flang/Common/optional.h"
 #include "flang/Runtime/descriptor.h"
+#include "terminator.h"
 #include <cinttypes>
 #include <memory>
 
diff --git a/flang/unittests/Evaluate/fp-testing.cpp b/flang/unittests/Evaluate/fp-testing.cpp
index 94d8d5086d000b..893b10899181a9 100644
--- a/flang/unittests/Evaluate/fp-testing.cpp
+++ b/flang/unittests/Evaluate/fp-testing.cpp
@@ -8,7 +8,7 @@
 #endif
 
 using Fortran::common::RoundingMode;
-using Fortran::evaluate::RealFlag;
+using Fortran::common::RealFlag;
 
 ScopedHostFloatingPointEnvironment::ScopedHostFloatingPointEnvironment(
 #if __x86_64__
diff --git a/flang/unittests/Evaluate/fp-testing.h b/flang/unittests/Evaluate/fp-testing.h
index 22dfa2d7d80c60..5801eb2e86b745 100644
--- a/flang/unittests/Evaluate/fp-testing.h
+++ b/flang/unittests/Evaluate/fp-testing.h
@@ -1,12 +1,12 @@
 #ifndef FORTRAN_TEST_EVALUATE_FP_TESTING_H_
 #define FORTRAN_TEST_EVALUATE_FP_TESTING_H_
 
-#include "flang/Evaluate/target.h"
+#include "flang/Common/target-rounding.h"
 #include <fenv.h>
 
 using Fortran::common::RoundingMode;
-using Fortran::evaluate::RealFlags;
-using Fortran::evaluate::Rounding;
+using Fortran::common::RealFlags;
+using Fortran::common::Rounding;
 
 class ScopedHostFloatingPointEnvironment {
 public:
diff --git a/flang/unittests/Runtime/Complex.cpp b/flang/unittests/Runtime/Complex.cpp
index 46f3ad2f2712b2..d714da24dc4e58 100644
--- a/flang/unittests/Runtime/Complex.cpp
+++ b/flang/unittests/Runtime/Complex.cpp
@@ -13,7 +13,7 @@
 #pragma clang diagnostic ignored "-Wc99-extensions"
 #endif
 
-#include "flang/Common/Fortran.h"
+#include "flang/Common/Fortran-consts.h"
 #include "flang/Runtime/cpp-type.h"
 #include "flang/Runtime/entry-names.h"
 

>From 6071ac6cf02cef644c0a60249308c90e82d781b6 Mon Sep 17 00:00:00 2001
From: Michael Kruse <llvm-project at meinersbur.de>
Date: Fri, 27 Sep 2024 13:26:54 +0200
Subject: [PATCH 3/6] clang-format

---
 flang/include/flang/Common/Fortran.h    | 2 +-
 flang/runtime/type-info.h               | 2 +-
 flang/unittests/Evaluate/fp-testing.cpp | 2 +-
 flang/unittests/Evaluate/fp-testing.h   | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/flang/include/flang/Common/Fortran.h b/flang/include/flang/Common/Fortran.h
index 7c8d788dd563d9..623607d4fad267 100644
--- a/flang/include/flang/Common/Fortran.h
+++ b/flang/include/flang/Common/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 "flang/Common/Fortran-consts.h"
 #include "enum-set.h"
 #include "idioms.h"
+#include "flang/Common/Fortran-consts.h"
 #include <cinttypes>
 #include <optional>
 #include <string>
diff --git a/flang/runtime/type-info.h b/flang/runtime/type-info.h
index 3ccab0ff73ed20..32403b1db5169e 100644
--- a/flang/runtime/type-info.h
+++ b/flang/runtime/type-info.h
@@ -12,11 +12,11 @@
 // A C++ perspective of the derived type description schemata in
 // flang/module/__fortran_type_info.f90.
 
+#include "terminator.h"
 #include "flang/Common/Fortran-consts.h"
 #include "flang/Common/bit-population-count.h"
 #include "flang/Common/optional.h"
 #include "flang/Runtime/descriptor.h"
-#include "terminator.h"
 #include <cinttypes>
 #include <memory>
 
diff --git a/flang/unittests/Evaluate/fp-testing.cpp b/flang/unittests/Evaluate/fp-testing.cpp
index 893b10899181a9..1a1d7425d58249 100644
--- a/flang/unittests/Evaluate/fp-testing.cpp
+++ b/flang/unittests/Evaluate/fp-testing.cpp
@@ -7,8 +7,8 @@
 #include <xmmintrin.h>
 #endif
 
-using Fortran::common::RoundingMode;
 using Fortran::common::RealFlag;
+using Fortran::common::RoundingMode;
 
 ScopedHostFloatingPointEnvironment::ScopedHostFloatingPointEnvironment(
 #if __x86_64__
diff --git a/flang/unittests/Evaluate/fp-testing.h b/flang/unittests/Evaluate/fp-testing.h
index 5801eb2e86b745..9091963a99b32d 100644
--- a/flang/unittests/Evaluate/fp-testing.h
+++ b/flang/unittests/Evaluate/fp-testing.h
@@ -4,9 +4,9 @@
 #include "flang/Common/target-rounding.h"
 #include <fenv.h>
 
-using Fortran::common::RoundingMode;
 using Fortran::common::RealFlags;
 using Fortran::common::Rounding;
+using Fortran::common::RoundingMode;
 
 class ScopedHostFloatingPointEnvironment {
 public:

>From 98c71d8b21084841d068fe77d117b506f1809e69 Mon Sep 17 00:00:00 2001
From: "U-BERGUFFLEN\\meinersbur" <llvm-project at meinersbur.de>
Date: Fri, 27 Sep 2024 17:16:16 +0200
Subject: [PATCH 4/6] Normlize header guards

---
 flang/include/flang/Common/Fortran-consts.h  | 2 +-
 flang/include/flang/Common/target-rounding.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/flang/include/flang/Common/Fortran-consts.h b/flang/include/flang/Common/Fortran-consts.h
index 3d4377dd5a076c..eedcdae335c400 100644
--- a/flang/include/flang/Common/Fortran-consts.h
+++ b/flang/include/flang/Common/Fortran-consts.h
@@ -41,4 +41,4 @@ enum class RoundingMode : std::uint8_t {
 };
 
 } // namespace Fortran::common
-#endif // FORTRAN_COMMON_FORTRAN_CONSTS_H_
+#endif /* FORTRAN_COMMON_FORTRAN_CONSTS_H_ */
diff --git a/flang/include/flang/Common/target-rounding.h b/flang/include/flang/Common/target-rounding.h
index e31920f5f6343e..c0c9f6c49b26a2 100644
--- a/flang/include/flang/Common/target-rounding.h
+++ b/flang/include/flang/Common/target-rounding.h
@@ -34,4 +34,4 @@ ENUM_CLASS(RealFlag, InvalidArgument, Denorm, DivideByZero, Overflow, Underflow,
 using RealFlags = common::EnumSet<RealFlag, RealFlag_enumSize>;
 
 } // namespace Fortran::common
-#endif // FORTRAN_COMMON_TARGET_ROUNDING_H_
+#endif /* FORTRAN_COMMON_TARGET_ROUNDING_H_ */

>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 5/6] 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>
 

>From 7c697c49dc220449676a6f641a7624106d1df709 Mon Sep 17 00:00:00 2001
From: Michael Kruse <llvm-project at meinersbur.de>
Date: Fri, 27 Sep 2024 18:58:16 +0200
Subject: [PATCH 6/6] Cleanup + reduce patch size

---
 .../include/flang/Common/Fortran-consts.h     |   8 +-
 .../flang/Common/ISO_Fortran_binding.h        |   8 +-
 .../Common/ISO_Fortran_binding_wrapper.h      |   8 +-
 .../include/flang/Common/api-attrs.h          |   6 +-
 .../flang/Common/binary-floating-point.h      |   6 +-
 .../flang/Common/bit-population-count.h       |   2 +-
 .../include/flang/Common/constexpr-bitset.h   |   2 +-
 FortranRuntime/include/flang/Common/decimal.h |   6 +-
 .../include/flang/Common/enum-class.h         |   2 +-
 .../include/flang/Common/enum-set.h           |   2 +-
 .../include/flang/Common/fast-int-set.h       |   2 +-
 FortranRuntime/include/flang/Common/format.h  |   2 +-
 FortranRuntime/include/flang/Common/idioms.h  |   2 +-
 .../flang/Common/leading-zero-bit-count.h     |   2 +-
 .../include/flang/Common/optional.h           |   6 +-
 FortranRuntime/include/flang/Common/real.h    |   2 +-
 .../include/flang/Common/reference-wrapper.h  |   6 +-
 .../include/flang/Common/restorer.h           |   4 +-
 .../include/flang/Common/target-rounding.h    |   7 +-
 FortranRuntime/include/flang/Common/uint128.h |   4 +-
 FortranRuntime/include/flang/Common/variant.h |   6 +-
 FortranRuntime/include/flang/Common/visit.h   |   4 +-
 .../include/flang/Common/windows-include.h    |   2 +-
 .../include/flang/Runtime/CUDA/allocator.h    |   2 +-
 .../include/flang/Runtime/CUDA/descriptor.h   |   2 +-
 .../include/flang/Runtime/allocatable.h       |   2 +-
 .../flang/Runtime/allocator-registry.h        |   6 +-
 .../include/flang/Runtime/array-constructor.h |   6 +-
 FortranRuntime/include/flang/Runtime/assign.h |   2 +-
 .../include/flang/Runtime/c-or-cpp.h          |   2 +-
 .../include/flang/Runtime/character.h         |   2 +-
 .../include/flang/Runtime/command.h           |   2 +-
 .../include/flang/Runtime/cpp-type.h          |   2 +-
 .../include/flang/Runtime/derived-api.h       |   2 +-
 .../include/flang/Runtime/descriptor.h        |   2 +-
 .../include/flang/Runtime/entry-names.h       |   6 +-
 .../include/flang/Runtime/exceptions.h        |   2 +-
 .../include/flang/Runtime/execute.h           |   2 +-
 .../include/flang/Runtime/extensions.h        |   2 +-
 .../flang/Runtime/freestanding-tools.h        |   2 +-
 .../include/flang/Runtime/inquiry.h           |   2 +-
 FortranRuntime/include/flang/Runtime/io-api.h |   2 +-
 FortranRuntime/include/flang/Runtime/iostat.h |   2 +-
 FortranRuntime/include/flang/Runtime/main.h   |   2 +-
 .../include/flang/Runtime/matmul-transpose.h  |   2 +-
 FortranRuntime/include/flang/Runtime/matmul.h |   2 +-
 FortranRuntime/include/flang/Runtime/memory.h |   2 +-
 .../include/flang/Runtime/misc-intrinsic.h    |   2 +-
 .../include/flang/Runtime/numeric.h           |   2 +-
 .../include/flang/Runtime/pointer.h           |   2 +-
 FortranRuntime/include/flang/Runtime/ragged.h |   2 +-
 FortranRuntime/include/flang/Runtime/random.h |   5 +
 FortranRuntime/include/flang/Runtime/reduce.h |   2 +-
 .../include/flang/Runtime/reduction.h         |   2 +-
 FortranRuntime/include/flang/Runtime/stop.h   |   2 +-
 .../include/flang/Runtime/support.h           |   2 +-
 .../include/flang/Runtime/temporary-stack.h   |   2 +-
 .../include/flang/Runtime/time-intrinsic.h    |   2 +-
 .../include/flang/Runtime/transformational.h  |   2 +-
 .../include/flang/Runtime/type-code.h         |   4 +-
 .../include/flang/Testing/fp-testing.h        |   8 +-
 .../include/flang/Testing/testing.h           |   6 +-
 .../lib/Common/big-radix-floating-point.h     |  10 +-
 .../lib/Common/decimal-to-binary.cpp          |   4 +-
 FortranRuntime/lib/Runtime/CMakeLists.txt     |  20 -
 .../lib/Runtime/CUDA/CMakeLists.txt           |   2 +-
 FortranRuntime/lib/Runtime/CUDA/allocator.cpp |   2 +-
 .../lib/Runtime/Float128Math/CMakeLists.txt   |   2 +-
 .../lib/Runtime/Float128Math/math-entries.h   |   6 +-
 .../Float128Math/numeric-template-specs.h     |   2 +-
 .../lib/Runtime/ISO_Fortran_binding.cpp       |   2 +-
 FortranRuntime/lib/Runtime/ISO_Fortran_util.h |   4 +-
 FortranRuntime/lib/Runtime/allocatable.cpp    |   6 +-
 .../lib/Runtime/array-constructor.cpp         |   6 +-
 FortranRuntime/lib/Runtime/assign-impl.h      |   2 +-
 FortranRuntime/lib/Runtime/assign.cpp         |   2 +-
 FortranRuntime/lib/Runtime/buffer.h           |   4 +-
 FortranRuntime/lib/Runtime/character.cpp      |   4 +-
 FortranRuntime/lib/Runtime/command.cpp        |   2 +-
 .../lib/Runtime/complex-reduction.h           |   2 +-
 FortranRuntime/lib/Runtime/connection.h       |   8 +-
 FortranRuntime/lib/Runtime/copy.cpp           |   4 +-
 FortranRuntime/lib/Runtime/copy.h             |   2 +-
 FortranRuntime/lib/Runtime/derived-api.cpp    |   2 +-
 FortranRuntime/lib/Runtime/derived.cpp        |   2 +-
 FortranRuntime/lib/Runtime/derived.h          |   2 +-
 FortranRuntime/lib/Runtime/descriptor-io.h    |  10 +-
 FortranRuntime/lib/Runtime/descriptor.cpp     |   2 +-
 FortranRuntime/lib/Runtime/dot-product.cpp    |   6 +-
 FortranRuntime/lib/Runtime/edit-input.cpp     |   4 +-
 FortranRuntime/lib/Runtime/edit-input.h       |   4 +-
 FortranRuntime/lib/Runtime/edit-output.cpp    |   2 +-
 FortranRuntime/lib/Runtime/edit-output.h      |   6 +-
 FortranRuntime/lib/Runtime/emit-encoded.h     |   2 +-
 FortranRuntime/lib/Runtime/environment.h      |   4 +-
 FortranRuntime/lib/Runtime/execute.cpp        |   2 +-
 FortranRuntime/lib/Runtime/extensions.cpp     |   4 +-
 FortranRuntime/lib/Runtime/extrema.cpp        |   2 +-
 FortranRuntime/lib/Runtime/file.cpp           |   2 +-
 FortranRuntime/lib/Runtime/file.h             |   4 +-
 FortranRuntime/lib/Runtime/findloc.cpp        |   2 +-
 .../lib/Runtime/format-implementation.h       |   8 +-
 FortranRuntime/lib/Runtime/format.h           |   6 +-
 FortranRuntime/lib/Runtime/inquiry.cpp        |   2 +-
 FortranRuntime/lib/Runtime/internal-unit.cpp  |   2 +-
 FortranRuntime/lib/Runtime/internal-unit.h    |   6 +-
 FortranRuntime/lib/Runtime/io-api-common.h    |  12 +-
 FortranRuntime/lib/Runtime/io-api-minimal.cpp |   2 +-
 FortranRuntime/lib/Runtime/io-api.cpp         |   6 +-
 FortranRuntime/lib/Runtime/io-error.cpp       |   2 +-
 FortranRuntime/lib/Runtime/io-error.h         |   4 +-
 FortranRuntime/lib/Runtime/io-stmt.cpp        |   2 +-
 FortranRuntime/lib/Runtime/io-stmt.h          |   8 +-
 FortranRuntime/lib/Runtime/lock.h             |   2 +-
 .../lib/Runtime/matmul-transpose.cpp          |   4 +-
 FortranRuntime/lib/Runtime/matmul.cpp         |   4 +-
 FortranRuntime/lib/Runtime/memory.cpp         |   2 +-
 FortranRuntime/lib/Runtime/misc-intrinsic.cpp |   4 +-
 FortranRuntime/lib/Runtime/namelist.cpp       |   2 +-
 FortranRuntime/lib/Runtime/namelist.h         |   4 +-
 FortranRuntime/lib/Runtime/non-tbp-dio.h      |   2 +-
 .../lib/Runtime/numeric-templates.h           |   6 +-
 FortranRuntime/lib/Runtime/numeric.cpp        |   2 +-
 FortranRuntime/lib/Runtime/product.cpp        |   2 +-
 FortranRuntime/lib/Runtime/random-templates.h |   6 +-
 FortranRuntime/lib/Runtime/random.cpp         |   6 +-
 FortranRuntime/lib/Runtime/reduce.cpp         |   2 +-
 .../lib/Runtime/reduction-templates.h         |   6 +-
 FortranRuntime/lib/Runtime/reduction.cpp      |   2 +-
 FortranRuntime/lib/Runtime/stack.h            |   8 +-
 FortranRuntime/lib/Runtime/stat.cpp           |   2 +-
 FortranRuntime/lib/Runtime/stat.h             |   4 +-
 FortranRuntime/lib/Runtime/sum.cpp            |   2 +-
 FortranRuntime/lib/Runtime/support.cpp        |   2 +-
 .../lib/Runtime/temporary-stack.cpp           |   2 +-
 FortranRuntime/lib/Runtime/terminator.h       |   2 +-
 FortranRuntime/lib/Runtime/time-intrinsic.cpp |   4 +-
 FortranRuntime/lib/Runtime/tools.h            |   6 +-
 .../lib/Runtime/transformational.cpp          |   4 +-
 FortranRuntime/lib/Runtime/type-info.h        |   4 +-
 FortranRuntime/lib/Runtime/unit-map.h         |   6 +-
 FortranRuntime/lib/Runtime/unit.h             |  12 +-
 FortranRuntime/lib/Runtime/utf.h              |   2 +-
 FortranRuntime/lib/Testing/fp-testing.cpp     |   8 -
 .../unittests/Common/FastIntSetTest.cpp       |   2 +-
 .../Evaluate/ISO-Fortran-binding.cpp          |   2 +-
 FortranRuntime/unittests/Evaluate/reshape.cpp |   2 +-
 .../unittests/Runtime/AccessTest.cpp          |   2 +-
 .../unittests/Runtime/Allocatable.cpp         |   2 +-
 .../unittests/Runtime/ArrayConstructor.cpp    |   4 +-
 .../unittests/Runtime/CUDA/AllocatorCUF.cpp   |   4 +-
 .../unittests/Runtime/CharacterTest.cpp       |   2 +-
 .../unittests/Runtime/CommandTest.cpp         |   4 +-
 FortranRuntime/unittests/Runtime/Complex.cpp  |   2 +-
 .../unittests/Runtime/CrashHandlerFixture.h   |   6 +-
 FortranRuntime/unittests/Runtime/Derived.cpp  |   4 +-
 .../unittests/Runtime/ExternalIOTest.cpp      |   2 +-
 FortranRuntime/unittests/Runtime/Inquiry.cpp  |   4 +-
 .../unittests/Runtime/ListInputTest.cpp       |   2 +-
 FortranRuntime/unittests/Runtime/Matmul.cpp   |   4 +-
 .../unittests/Runtime/MatmulTranspose.cpp     |   4 +-
 .../unittests/Runtime/MiscIntrinsic.cpp       |   4 +-
 FortranRuntime/unittests/Runtime/Namelist.cpp |   2 +-
 FortranRuntime/unittests/Runtime/Numeric.cpp  |   2 +-
 FortranRuntime/unittests/Runtime/Pointer.cpp  |   4 +-
 FortranRuntime/unittests/Runtime/Random.cpp   |   2 +-
 .../unittests/Runtime/Reduction.cpp           |   4 +-
 .../unittests/Runtime/RuntimeCrashTest.cpp    |   4 +-
 FortranRuntime/unittests/Runtime/Stop.cpp     |   2 +-
 FortranRuntime/unittests/Runtime/Support.cpp  |   4 +-
 .../unittests/Runtime/TemporaryStack.cpp      |   4 +-
 FortranRuntime/unittests/Runtime/Time.cpp     |   2 +-
 .../unittests/Runtime/Transformational.cpp    |   4 +-
 FortranRuntime/unittests/Runtime/tools.h      |   4 +-
 flang/CMakeLists.txt                          |   2 +
 flang/include/flang/Evaluate/call.h           |   4 +-
 .../include/flang/Evaluate/characteristics.h  |   6 +-
 flang/include/flang/Evaluate/common.h         |  16 +-
 flang/include/flang/Evaluate/expression.h     |   4 +-
 flang/include/flang/Evaluate/intrinsics.h     |   2 +-
 flang/include/flang/Evaluate/shape.h          |   2 +-
 flang/include/flang/Evaluate/target.h         |   2 +-
 flang/include/flang/Evaluate/tools.h          |   4 +-
 flang/include/flang/Evaluate/traverse.h       |   2 +-
 flang/include/flang/Evaluate/type.h           |   4 +-
 flang/include/flang/Evaluate/variable.h       |   2 +-
 .../include/flang/Frontend/FrontendOptions.h  |   2 +-
 flang/include/flang/Lower/AbstractConverter.h |   2 +-
 flang/include/flang/Lower/Bridge.h            |   2 +-
 flang/include/flang/Lower/CallInterface.h     |   2 +-
 flang/include/flang/Lower/ConvertType.h       |   2 +-
 flang/include/flang/Lower/PFTBuilder.h        |   4 +-
 flang/include/flang/Lower/Support/Utils.h     |   2 +-
 flang/include/flang/Lower/SymbolMap.h         |   2 +-
 .../flang/Optimizer/Builder/FIRBuilder.h      |   2 +-
 .../Optimizer/Builder/PPCIntrinsicCall.h      |   2 +-
 .../Optimizer/Builder/Runtime/RTBuilder.h     |   2 +-
 flang/include/flang/Optimizer/Support/Utils.h |   2 +-
 flang/include/flang/Parser/dump-parse-tree.h  |   2 +-
 flang/include/flang/Parser/message.h          |   2 +-
 flang/include/flang/Parser/parse-state.h      |   2 +-
 flang/include/flang/Parser/parse-tree.h       |   2 +-
 flang/include/flang/Parser/parsing.h          |   2 +-
 flang/include/flang/Parser/user-state.h       |   2 +-
 flang/include/flang/Semantics/expression.h    |   4 +-
 .../flang/Semantics/runtime-type-info.h       |   2 +-
 flang/include/flang/Semantics/scope.h         |   4 +-
 flang/include/flang/Semantics/semantics.h     |   2 +-
 flang/include/flang/Semantics/symbol.h        |   4 +-
 flang/include/flang/Semantics/tools.h         |   2 +-
 flang/include/flang/Semantics/type.h          |   2 +-
 .../include/flang/Support/Fortran-features.h  |   2 +-
 flang/include/flang/Support/Fortran.h         |  16 +-
 flang/include/flang/Support/template.h        |   2 +-
 flang/include/flang/Tools/CrossToolHelpers.h  |   2 +-
 flang/lib/Common/CMakeLists.txt               |   8 -
 flang/lib/Evaluate/call.cpp                   |   2 +-
 flang/lib/Evaluate/characteristics.cpp        |   2 +-
 flang/lib/Evaluate/common.cpp                 |   1 -
 flang/lib/Evaluate/fold-implementation.h      |   6 +-
 flang/lib/Evaluate/formatting.cpp             |   2 +-
 flang/lib/Evaluate/intrinsics-library.cpp     |   2 +-
 flang/lib/Evaluate/intrinsics.cpp             |   2 +-
 flang/lib/Evaluate/real.cpp                   |   2 +-
 flang/lib/Evaluate/shape.cpp                  |   2 +-
 flang/lib/Evaluate/target.cpp                 |   2 +-
 flang/lib/Frontend/CompilerInstance.cpp       |   2 +-
 flang/lib/Frontend/CompilerInvocation.cpp     |   6 +-
 flang/lib/Frontend/FrontendActions.cpp        |   2 +-
 flang/lib/Lower/Bridge.cpp                    |   2 +-
 flang/lib/Lower/CallInterface.cpp             |   2 +-
 flang/lib/Lower/ConvertExpr.cpp               |   4 +-
 flang/lib/Lower/Mangler.cpp                   |   2 +-
 flang/lib/Optimizer/Builder/IntrinsicCall.cpp |   8 +-
 flang/lib/Optimizer/CodeGen/TypeConverter.cpp |   2 +-
 .../lib/Optimizer/Transforms/AddDebugInfo.cpp |   2 +-
 .../Transforms/AssumedRankOpConversion.cpp    |   2 +-
 .../Optimizer/Transforms/CufOpConversion.cpp  |   2 +-
 .../Transforms/ExternalNameConversion.cpp     |   2 +-
 .../Transforms/SimplifyIntrinsics.cpp         |   2 +-
 .../lib/Optimizer/Transforms/StackReclaim.cpp |   2 +-
 flang/lib/Parser/basic-parsers.h              |   4 +-
 flang/lib/Parser/parse-tree.cpp               |   2 +-
 flang/lib/Parser/prescan.h                    |   2 +-
 flang/lib/Parser/unparse.cpp                  |   4 +-
 flang/lib/Semantics/assignment.h              |   2 +-
 flang/lib/Semantics/check-case.cpp            |   4 +-
 flang/lib/Semantics/check-coarray.cpp         |   2 +-
 flang/lib/Semantics/check-cuda.cpp            |   2 +-
 flang/lib/Semantics/check-data.h              |   2 +-
 flang/lib/Semantics/check-do-forall.cpp       |   2 +-
 flang/lib/Semantics/check-return.cpp          |   2 +-
 flang/lib/Semantics/check-select-rank.cpp     |   2 +-
 flang/lib/Semantics/check-select-type.cpp     |   2 +-
 flang/lib/Semantics/check-stop.cpp            |   2 +-
 flang/lib/Semantics/data-to-inits.h           |   4 +-
 flang/lib/Semantics/expression.cpp            |   2 +-
 flang/lib/Semantics/pointer-assignment.cpp    |   2 +-
 flang/lib/Semantics/resolve-labels.cpp        |   2 +-
 flang/lib/Semantics/resolve-names-utils.cpp   |   6 +-
 flang/lib/Semantics/resolve-names.cpp         |   6 +-
 flang/lib/Semantics/rewrite-parse-tree.cpp    |   2 +-
 flang/lib/Semantics/semantics.cpp             |   2 +-
 flang/lib/Semantics/tools.cpp                 |   4 +-
 flang/lib/Support/Fortran-features.cpp        |   2 +-
 flang/lib/Support/big-radix-floating-point.h  | 396 ------------------
 flang/test/CMakeLists.txt                     |   1 -
 flang/tools/bbc/bbc.cpp                       |   8 +-
 flang/tools/f18-parse-demo/f18-parse-demo.cpp |   4 +-
 flang/unittests/Evaluate/expression.cpp       |   2 +-
 flang/unittests/Evaluate/folding.cpp          |   2 +-
 flang/unittests/Evaluate/intrinsics.cpp       |   2 +-
 flang/unittests/Evaluate/logical.cpp          |   2 +-
 flang/unittests/Evaluate/real.cpp             |   2 +-
 lld/COFF/MinGW.cpp                            |   1 -
 llvm/projects/CMakeLists.txt                  |   1 -
 llvm/runtimes/CMakeLists.txt                  |   7 -
 runtimes/CMakeLists.txt                       |   1 -
 278 files changed, 441 insertions(+), 897 deletions(-)
 delete mode 100644 flang/lib/Support/big-radix-floating-point.h

diff --git a/FortranRuntime/include/flang/Common/Fortran-consts.h b/FortranRuntime/include/flang/Common/Fortran-consts.h
index 3156c6c50c3b9a..eedcdae335c400 100644
--- a/FortranRuntime/include/flang/Common/Fortran-consts.h
+++ b/FortranRuntime/include/flang/Common/Fortran-consts.h
@@ -9,9 +9,6 @@
 #ifndef FORTRAN_COMMON_FORTRAN_CONSTS_H_
 #define FORTRAN_COMMON_FORTRAN_CONSTS_H_
 
-// Fortran language concepts that are used in many phases are defined
-// once here to avoid redundancy and needless translation.
-
 #include "flang/Common/enum-class.h"
 #include <cstdint>
 
@@ -21,7 +18,6 @@ namespace Fortran::common {
 ENUM_CLASS(TypeCategory, Integer, Real, Complex, Character, Logical, Derived)
 ENUM_CLASS(VectorElementCategory, Integer, Unsigned, Real)
 
-
 ENUM_CLASS(IoStmtKind, None, Backspace, Close, Endfile, Flush, Inquire, Open,
     Print, Read, Rewind, Wait, Write)
 
@@ -32,7 +28,6 @@ ENUM_CLASS(
 // Fortran arrays may have up to 15 dimensions (See Fortran 2018 section 5.4.6).
 static constexpr int maxRank{15};
 
-
 // Floating-point rounding modes; these are packed into a byte to save
 // room in the runtime's format processing context structure.  These
 // enumerators are defined with the corresponding values returned from
@@ -45,6 +40,5 @@ enum class RoundingMode : std::uint8_t {
   TiesAwayFromZero, // ROUND=COMPATIBLE, RC - ties round away from zero
 };
 
-
 } // namespace Fortran::common
-#endif // FORTRAN_COMMON_FORTRAN_CONSTS_H_
+#endif /* FORTRAN_COMMON_FORTRAN_CONSTS_H_ */
diff --git a/FortranRuntime/include/flang/Common/ISO_Fortran_binding.h b/FortranRuntime/include/flang/Common/ISO_Fortran_binding.h
index 21247103bcc552..516355c01ec7d0 100644
--- a/FortranRuntime/include/flang/Common/ISO_Fortran_binding.h
+++ b/FortranRuntime/include/flang/Common/ISO_Fortran_binding.h
@@ -6,14 +6,14 @@
  *
  *===----------------------------------------------------------------------===*/
 
-#ifndef CFI_ISO_FORTRAN_BINDING_H_
-#define CFI_ISO_FORTRAN_BINDING_H_
+#ifndef FORTRAN_COMMON_ISO_FORTRAN_BINDING_H_
+#define FORTRAN_COMMON_ISO_FORTRAN_BINDING_H_
 
 /* When this header is included into the compiler and runtime implementations,
  * it does so by means of a wrapper header that establishes namespaces and
  * a macro for extra function attributes (RT_API_ATTRS).
  */
-#ifndef FORTRAN_ISO_FORTRAN_BINDING_WRAPPER_H_
+#ifndef FORTRAN_COMMON_ISO_FORTRAN_BINDING_WRAPPER_H_
 #include <stddef.h>
 #define FORTRAN_ISO_NAMESPACE_
 #endif
@@ -206,4 +206,4 @@ RT_API_ATTRS int CFI_setpointer(
 } // extern "C"
 #endif
 
-#endif /* CFI_ISO_FORTRAN_BINDING_H_ */
+#endif /* FORTRAN_COMMON_ISO_FORTRAN_BINDING_H_ */
diff --git a/FortranRuntime/include/flang/Common/ISO_Fortran_binding_wrapper.h b/FortranRuntime/include/flang/Common/ISO_Fortran_binding_wrapper.h
index ee02f6f129732e..d1bc9be34859a4 100644
--- a/FortranRuntime/include/flang/Common/ISO_Fortran_binding_wrapper.h
+++ b/FortranRuntime/include/flang/Common/ISO_Fortran_binding_wrapper.h
@@ -6,8 +6,8 @@
  *
  *===----------------------------------------------------------------------===*/
 
-#ifndef FORTRAN_ISO_FORTRAN_BINDING_WRAPPER_H_
-#define FORTRAN_ISO_FORTRAN_BINDING_WRAPPER_H_
+#ifndef FORTRAN_COMMON_ISO_FORTRAN_BINDING_WRAPPER_H_
+#define FORTRAN_COMMON_ISO_FORTRAN_BINDING_WRAPPER_H_
 
 /* A thin wrapper around flang/include/ISO_Fortran_binding.h
  * This header file must be included when ISO_Fortran_binding.h
@@ -22,7 +22,7 @@
 
 /* clang-format off */
 #include <stddef.h>
-#include "flang/Common/api-attrs.h"
+#include "flang/Common/api-attrs.h" 
 #ifdef __cplusplus
 namespace Fortran {
 namespace ISO {
@@ -35,4 +35,4 @@ namespace ISO {
 #endif /* __cplusplus */
 /* clang-format on */
 
-#endif /* FORTRAN_ISO_FORTRAN_BINDING_WRAPPER_H_ */
+#endif /* FORTRAN_COMMON_ISO_FORTRAN_BINDING_WRAPPER_H_ */
diff --git a/FortranRuntime/include/flang/Common/api-attrs.h b/FortranRuntime/include/flang/Common/api-attrs.h
index b56a3c8a047af6..9a3001fb255c11 100644
--- a/FortranRuntime/include/flang/Common/api-attrs.h
+++ b/FortranRuntime/include/flang/Common/api-attrs.h
@@ -12,8 +12,8 @@
  * declared/defined/used in Flang runtime library.
  */
 
-#ifndef FORTRAN_RUNTIME_API_ATTRS_H_
-#define FORTRAN_RUNTIME_API_ATTRS_H_
+#ifndef FORTRAN_COMMON_API_ATTRS_H_
+#define FORTRAN_COMMON_API_ATTRS_H_
 
 /*
  * RT_EXT_API_GROUP_BEGIN/END pair is placed around definitions
@@ -177,4 +177,4 @@
 #define RT_DEVICE_NOINLINE_HOST_INLINE inline
 #endif
 
-#endif /* !FORTRAN_RUNTIME_API_ATTRS_H_ */
+#endif /* FORTRAN_COMMON_API_ATTRS_H_ */
diff --git a/FortranRuntime/include/flang/Common/binary-floating-point.h b/FortranRuntime/include/flang/Common/binary-floating-point.h
index 1409b94192740c..705acc31bdfb21 100644
--- a/FortranRuntime/include/flang/Common/binary-floating-point.h
+++ b/FortranRuntime/include/flang/Common/binary-floating-point.h
@@ -6,8 +6,8 @@
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef FORTRAN_DECIMAL_BINARY_FLOATING_POINT_H_
-#define FORTRAN_DECIMAL_BINARY_FLOATING_POINT_H_
+#ifndef FORTRAN_COMMON_BINARY_FLOATING_POINT_H_
+#define FORTRAN_COMMON_BINARY_FLOATING_POINT_H_
 
 // Access and manipulate the fields of an IEEE-754 binary
 // floating-point value via a generalized template.
@@ -208,4 +208,4 @@ template <int BINARY_PRECISION> class BinaryFloatingPointNumber {
   RawType raw_{0};
 };
 } // namespace Fortran::decimal
-#endif
+#endif /* FORTRAN_COMMON_BINARY_FLOATING_POINT_H_ */
diff --git a/FortranRuntime/include/flang/Common/bit-population-count.h b/FortranRuntime/include/flang/Common/bit-population-count.h
index e1aeb78f9a3765..59ade914d14d85 100644
--- a/FortranRuntime/include/flang/Common/bit-population-count.h
+++ b/FortranRuntime/include/flang/Common/bit-population-count.h
@@ -93,4 +93,4 @@ template <typename INT> inline constexpr int TrailingZeroBitCount(INT x) {
   }
 }
 } // namespace Fortran::common
-#endif // FORTRAN_COMMON_BIT_POPULATION_COUNT_H_
+#endif /* FORTRAN_COMMON_BIT_POPULATION_COUNT_H_ */
diff --git a/FortranRuntime/include/flang/Common/constexpr-bitset.h b/FortranRuntime/include/flang/Common/constexpr-bitset.h
index 1aafb6eff84c61..093b247b5f4eff 100644
--- a/FortranRuntime/include/flang/Common/constexpr-bitset.h
+++ b/FortranRuntime/include/flang/Common/constexpr-bitset.h
@@ -144,4 +144,4 @@ template <int BITS> class BitSet {
   Word bits_{0};
 };
 } // namespace Fortran::common
-#endif // FORTRAN_COMMON_CONSTEXPR_BITSET_H_
+#endif /* FORTRAN_COMMON_CONSTEXPR_BITSET_H_ */
diff --git a/FortranRuntime/include/flang/Common/decimal.h b/FortranRuntime/include/flang/Common/decimal.h
index 2a75b98c112225..c086f97129f6a5 100644
--- a/FortranRuntime/include/flang/Common/decimal.h
+++ b/FortranRuntime/include/flang/Common/decimal.h
@@ -8,8 +8,8 @@
 
 /* C and C++ API for binary-to/from-decimal conversion package. */
 
-#ifndef FORTRAN_DECIMAL_DECIMAL_H_
-#define FORTRAN_DECIMAL_DECIMAL_H_
+#ifndef FORTRAN_COMMON_DECIMAL_H_
+#define FORTRAN_COMMON_DECIMAL_H_
 
 #include "flang/Common/api-attrs.h"
 #include <stddef.h>
@@ -136,4 +136,4 @@ RT_API_ATTRS enum NS(ConversionResultFlags) ConvertDecimalToLongDouble(
 #ifdef __cplusplus
 } // extern "C"
 #endif
-#endif
+#endif /* FORTRAN_COMMON_DECIMAL_H_ */
diff --git a/FortranRuntime/include/flang/Common/enum-class.h b/FortranRuntime/include/flang/Common/enum-class.h
index 41575d45091a8d..787648ffec48e8 100644
--- a/FortranRuntime/include/flang/Common/enum-class.h
+++ b/FortranRuntime/include/flang/Common/enum-class.h
@@ -69,4 +69,4 @@ constexpr std::array<std::string_view, ITEMS> EnumNames(const char *p) {
   }
 
 } // namespace Fortran::common
-#endif // FORTRAN_COMMON_ENUM_CLASS_H_
+#endif /* FORTRAN_COMMON_ENUM_CLASS_H_ */
diff --git a/FortranRuntime/include/flang/Common/enum-set.h b/FortranRuntime/include/flang/Common/enum-set.h
index 5290b76debee88..6100fc5e2e31c5 100644
--- a/FortranRuntime/include/flang/Common/enum-set.h
+++ b/FortranRuntime/include/flang/Common/enum-set.h
@@ -228,4 +228,4 @@ struct std::hash<Fortran::common::EnumSet<ENUM, values>> {
     return std::hash(x.bitset());
   }
 };
-#endif // FORTRAN_COMMON_ENUM_SET_H_
+#endif /* FORTRAN_COMMON_ENUM_SET_H_ */
diff --git a/FortranRuntime/include/flang/Common/fast-int-set.h b/FortranRuntime/include/flang/Common/fast-int-set.h
index 48209a773c4cd1..323ee4dc7e94d9 100644
--- a/FortranRuntime/include/flang/Common/fast-int-set.h
+++ b/FortranRuntime/include/flang/Common/fast-int-set.h
@@ -103,4 +103,4 @@ template <int N> class FastIntSet {
   bool isFullyInitialized_{false}; // memory was cleared
 };
 } // namespace Fortran::common
-#endif // FORTRAN_COMMON_FAST_INT_SET_H_
+#endif /* FORTRAN_COMMON_FAST_INT_SET_H_ */
diff --git a/FortranRuntime/include/flang/Common/format.h b/FortranRuntime/include/flang/Common/format.h
index 138e84b72b733d..6f4dfc8d2376b7 100644
--- a/FortranRuntime/include/flang/Common/format.h
+++ b/FortranRuntime/include/flang/Common/format.h
@@ -901,4 +901,4 @@ template <typename CHAR> bool FormatValidator<CHAR>::Check() {
 }
 
 } // namespace Fortran::common
-#endif // FORTRAN_COMMON_FORMAT_H_
+#endif /* FORTRAN_COMMON_FORMAT_H_ */
diff --git a/FortranRuntime/include/flang/Common/idioms.h b/FortranRuntime/include/flang/Common/idioms.h
index 99f383ec75b999..1ae0c0b35112e9 100644
--- a/FortranRuntime/include/flang/Common/idioms.h
+++ b/FortranRuntime/include/flang/Common/idioms.h
@@ -150,4 +150,4 @@ template <typename A, typename... B>
 using IfNoLvalue = std::enable_if_t<(... && !std::is_lvalue_reference_v<B>), A>;
 template <typename... RVREF> using NoLvalue = IfNoLvalue<void, RVREF...>;
 } // namespace Fortran::common
-#endif // FORTRAN_COMMON_IDIOMS_H_
+#endif /* FORTRAN_COMMON_IDIOMS_H_ */
diff --git a/FortranRuntime/include/flang/Common/leading-zero-bit-count.h b/FortranRuntime/include/flang/Common/leading-zero-bit-count.h
index a296e0b446917f..e788bfa9bcfd08 100644
--- a/FortranRuntime/include/flang/Common/leading-zero-bit-count.h
+++ b/FortranRuntime/include/flang/Common/leading-zero-bit-count.h
@@ -93,4 +93,4 @@ template <typename A> inline constexpr int BitsNeededFor(A x) {
   return 8 * sizeof x - LeadingZeroBitCount(x);
 }
 } // namespace Fortran::common
-#endif // FORTRAN_COMMON_LEADING_ZERO_BIT_COUNT_H_
+#endif /* FORTRAN_COMMON_LEADING_ZERO_BIT_COUNT_H_ */
diff --git a/FortranRuntime/include/flang/Common/optional.h b/FortranRuntime/include/flang/Common/optional.h
index c0f4278009f40a..c3db3b1329a2fd 100644
--- a/FortranRuntime/include/flang/Common/optional.h
+++ b/FortranRuntime/include/flang/Common/optional.h
@@ -23,8 +23,8 @@
 //   * cuda:: namespace need to be forced for all std:: references.
 //
 //===----------------------------------------------------------------------===//
-#ifndef FORTRAN_COMMON_OPTIONAL_H
-#define FORTRAN_COMMON_OPTIONAL_H
+#ifndef FORTRAN_COMMON_OPTIONAL_H_
+#define FORTRAN_COMMON_OPTIONAL_H_
 
 #include "flang/Common/api-attrs.h"
 #include <optional>
@@ -240,4 +240,4 @@ using std::optional;
 
 } // namespace Fortran::common
 
-#endif // FORTRAN_COMMON_OPTIONAL_H
+#endif /* FORTRAN_COMMON_OPTIONAL_H_ */
diff --git a/FortranRuntime/include/flang/Common/real.h b/FortranRuntime/include/flang/Common/real.h
index b527deda0e3b4f..dc9a2404731e70 100644
--- a/FortranRuntime/include/flang/Common/real.h
+++ b/FortranRuntime/include/flang/Common/real.h
@@ -141,4 +141,4 @@ class RealCharacteristics {
 };
 
 } // namespace Fortran::common
-#endif // FORTRAN_COMMON_REAL_H_
+#endif /* FORTRAN_COMMON_REAL_H_ */
diff --git a/FortranRuntime/include/flang/Common/reference-wrapper.h b/FortranRuntime/include/flang/Common/reference-wrapper.h
index 2983754108f95a..6822fb335f398c 100644
--- a/FortranRuntime/include/flang/Common/reference-wrapper.h
+++ b/FortranRuntime/include/flang/Common/reference-wrapper.h
@@ -22,8 +22,8 @@
 //
 // clang-format on
 
-#ifndef FORTRAN_COMMON_REFERENCE_WRAPPER_H
-#define FORTRAN_COMMON_REFERENCE_WRAPPER_H
+#ifndef FORTRAN_COMMON_REFERENCE_WRAPPER_H_
+#define FORTRAN_COMMON_REFERENCE_WRAPPER_H_
 
 #include "flang/Common/api-attrs.h"
 #include <functional>
@@ -111,4 +111,4 @@ using std::reference_wrapper;
 
 } // namespace Fortran::common
 
-#endif // FORTRAN_COMMON_REFERENCE_WRAPPER_H
+#endif /* FORTRAN_COMMON_REFERENCE_WRAPPER_H_ */
diff --git a/FortranRuntime/include/flang/Common/restorer.h b/FortranRuntime/include/flang/Common/restorer.h
index 0f1bc48620d37e..a5c5ebe7344a1b 100644
--- a/FortranRuntime/include/flang/Common/restorer.h
+++ b/FortranRuntime/include/flang/Common/restorer.h
@@ -18,8 +18,8 @@
 
 #ifndef FORTRAN_COMMON_RESTORER_H_
 #define FORTRAN_COMMON_RESTORER_H_
-#include "idioms.h"
 #include "flang/Common/api-attrs.h"
+#include "idioms.h"
 namespace Fortran::common {
 template <typename A> class Restorer {
 public:
@@ -53,4 +53,4 @@ RT_API_ATTRS common::IfNoLvalue<Restorer<A>, B> ScopedSet(
   return Restorer<A>{to, std::move(original)};
 }
 } // namespace Fortran::common
-#endif // FORTRAN_COMMON_RESTORER_H_
+#endif /* FORTRAN_COMMON_RESTORER_H_ */
diff --git a/FortranRuntime/include/flang/Common/target-rounding.h b/FortranRuntime/include/flang/Common/target-rounding.h
index 970d8fb61fbd1b..c0c9f6c49b26a2 100644
--- a/FortranRuntime/include/flang/Common/target-rounding.h
+++ b/FortranRuntime/include/flang/Common/target-rounding.h
@@ -9,11 +9,9 @@
 #ifndef FORTRAN_COMMON_TARGET_ROUNDING_H_
 #define FORTRAN_COMMON_TARGET_ROUNDING_H_
 
-
 #include "flang/Common/Fortran-consts.h"
 #include "flang/Common/enum-set.h"
 
-
 namespace Fortran::common {
 
 // Floating-point rounding control
@@ -30,11 +28,10 @@ struct Rounding {
 #endif
 };
 
-
 // These are ordered like the bits in a common fenv.h header file.
 ENUM_CLASS(RealFlag, InvalidArgument, Denorm, DivideByZero, Overflow, Underflow,
     Inexact)
 using RealFlags = common::EnumSet<RealFlag, RealFlag_enumSize>;
 
-}
-#endif // FORTRAN_COMMON_TARGET_ROUNDING_H_
+} // namespace Fortran::common
+#endif /* FORTRAN_COMMON_TARGET_ROUNDING_H_ */
diff --git a/FortranRuntime/include/flang/Common/uint128.h b/FortranRuntime/include/flang/Common/uint128.h
index 821c8c3b08a52f..1b2ee6a2c14b87 100644
--- a/FortranRuntime/include/flang/Common/uint128.h
+++ b/FortranRuntime/include/flang/Common/uint128.h
@@ -19,8 +19,8 @@
 #define AVOID_NATIVE_UINT128_T 0
 #endif
 
-#include "leading-zero-bit-count.h"
 #include "flang/Common/api-attrs.h"
+#include "leading-zero-bit-count.h"
 #include <cstdint>
 #include <type_traits>
 
@@ -303,4 +303,4 @@ template <int BITS>
 using HostSignedIntType = typename HostSignedIntTypeHelper<BITS>::type;
 
 } // namespace Fortran::common
-#endif
+#endif /* FORTRAN_COMMON_UINT128_H_ */
diff --git a/FortranRuntime/include/flang/Common/variant.h b/FortranRuntime/include/flang/Common/variant.h
index 1af85876afac00..ff9b1aed4eba91 100644
--- a/FortranRuntime/include/flang/Common/variant.h
+++ b/FortranRuntime/include/flang/Common/variant.h
@@ -11,8 +11,8 @@
 // and the related names become available, though, they may correspond
 // to alternative definitions (e.g. from cuda::std namespace).
 
-#ifndef FORTRAN_COMMON_VARIANT_H
-#define FORTRAN_COMMON_VARIANT_H
+#ifndef FORTRAN_COMMON_VARIANT_H_
+#define FORTRAN_COMMON_VARIANT_H_
 
 #if RT_USE_LIBCUDACXX
 #include <cuda/std/variant>
@@ -27,4 +27,4 @@ using cuda::std::visit;
 #include <variant>
 #endif // !RT_USE_LIBCUDACXX
 
-#endif // FORTRAN_COMMON_VARIANT_H
+#endif /* FORTRAN_COMMON_VARIANT_H_ */
diff --git a/FortranRuntime/include/flang/Common/visit.h b/FortranRuntime/include/flang/Common/visit.h
index ad66297650b093..8030ac9be173c3 100644
--- a/FortranRuntime/include/flang/Common/visit.h
+++ b/FortranRuntime/include/flang/Common/visit.h
@@ -21,8 +21,8 @@
 #ifndef FORTRAN_COMMON_VISIT_H_
 #define FORTRAN_COMMON_VISIT_H_
 
-#include "variant.h"
 #include "flang/Common/api-attrs.h"
+#include "variant.h"
 #include <type_traits>
 
 namespace Fortran::common {
@@ -100,4 +100,4 @@ using Fortran::common::log2visit::visit;
 #endif
 
 } // namespace Fortran::common
-#endif // FORTRAN_COMMON_VISIT_H_
+#endif /* FORTRAN_COMMON_VISIT_H_ */
diff --git a/FortranRuntime/include/flang/Common/windows-include.h b/FortranRuntime/include/flang/Common/windows-include.h
index 75ef4974251ff9..bee79d4fceb3ba 100644
--- a/FortranRuntime/include/flang/Common/windows-include.h
+++ b/FortranRuntime/include/flang/Common/windows-include.h
@@ -22,4 +22,4 @@
 
 #endif // _WIN32
 
-#endif // FORTRAN_COMMON_WINDOWS_INCLUDE_H_
+#endif /* FORTRAN_COMMON_WINDOWS_INCLUDE_H_ */
diff --git a/FortranRuntime/include/flang/Runtime/CUDA/allocator.h b/FortranRuntime/include/flang/Runtime/CUDA/allocator.h
index 4527c9f18fa054..48185e8f34eaf6 100644
--- a/FortranRuntime/include/flang/Runtime/CUDA/allocator.h
+++ b/FortranRuntime/include/flang/Runtime/CUDA/allocator.h
@@ -43,4 +43,4 @@ void *CUFAllocUnified(std::size_t);
 void CUFFreeUnified(void *);
 
 } // namespace Fortran::runtime::cuda
-#endif // FORTRAN_RUNTIME_CUDA_ALLOCATOR_H_
+#endif /* FORTRAN_RUNTIME_CUDA_ALLOCATOR_H_ */
diff --git a/FortranRuntime/include/flang/Runtime/CUDA/descriptor.h b/FortranRuntime/include/flang/Runtime/CUDA/descriptor.h
index d593989420420f..68ad0987d9aecd 100644
--- a/FortranRuntime/include/flang/Runtime/CUDA/descriptor.h
+++ b/FortranRuntime/include/flang/Runtime/CUDA/descriptor.h
@@ -27,4 +27,4 @@ void RTDECL(CUFFreeDesciptor)(
 
 } // extern "C"
 } // namespace Fortran::runtime::cuda
-#endif // FORTRAN_RUNTIME_CUDA_DESCRIPTOR_H_
+#endif /* FORTRAN_RUNTIME_CUDA_DESCRIPTOR_H_ */
diff --git a/FortranRuntime/include/flang/Runtime/allocatable.h b/FortranRuntime/include/flang/Runtime/allocatable.h
index 58061d9862095e..d7f3910074a760 100644
--- a/FortranRuntime/include/flang/Runtime/allocatable.h
+++ b/FortranRuntime/include/flang/Runtime/allocatable.h
@@ -129,4 +129,4 @@ void RTDECL(AllocatableDeallocateNoFinal)(
     Descriptor &, const char *sourceFile = nullptr, int sourceLine = 0);
 } // extern "C"
 } // namespace Fortran::runtime
-#endif // FORTRAN_RUNTIME_ALLOCATABLE_H_
+#endif /* FORTRAN_RUNTIME_ALLOCATABLE_H_ */
diff --git a/FortranRuntime/include/flang/Runtime/allocator-registry.h b/FortranRuntime/include/flang/Runtime/allocator-registry.h
index 411cc68f58ec33..4e7d9bcedfb375 100644
--- a/FortranRuntime/include/flang/Runtime/allocator-registry.h
+++ b/FortranRuntime/include/flang/Runtime/allocator-registry.h
@@ -6,8 +6,8 @@
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef FORTRAN_RUNTIME_ALLOCATOR_H_
-#define FORTRAN_RUNTIME_ALLOCATOR_H_
+#ifndef FORTRAN_RUNTIME_ALLOCATOR_REGISTRY_H_
+#define FORTRAN_RUNTIME_ALLOCATOR_REGISTRY_H_
 
 #include "flang/Common/api-attrs.h"
 #include <cstdlib>
@@ -62,4 +62,4 @@ RT_OFFLOAD_VAR_GROUP_END
 
 } // namespace Fortran::runtime
 
-#endif // FORTRAN_RUNTIME_ALLOCATOR_H_
+#endif /* FORTRAN_RUNTIME_ALLOCATOR_REGISTRY_H_ */
diff --git a/FortranRuntime/include/flang/Runtime/array-constructor.h b/FortranRuntime/include/flang/Runtime/array-constructor.h
index 46fc0418c7991e..82367756f5dc79 100644
--- a/FortranRuntime/include/flang/Runtime/array-constructor.h
+++ b/FortranRuntime/include/flang/Runtime/array-constructor.h
@@ -9,8 +9,8 @@
 // External APIs to create temporary storage for array constructors when their
 // final extents or length parameters cannot be pre-computed.
 
-#ifndef FORTRAN_RUNTIME_ARRAYCONSTRUCTOR_H_
-#define FORTRAN_RUNTIME_ARRAYCONSTRUCTOR_H_
+#ifndef FORTRAN_RUNTIME_ARRAY_CONSTRUCTOR_H_
+#define FORTRAN_RUNTIME_ARRAY_CONSTRUCTOR_H_
 
 #include "flang/Runtime/descriptor.h"
 #include "flang/Runtime/entry-names.h"
@@ -115,4 +115,4 @@ void RTDECL(PushArrayConstructorSimpleScalar)(
     ArrayConstructorVector &vector, void *from);
 } // extern "C"
 } // namespace Fortran::runtime
-#endif // FORTRAN_RUNTIME_ARRAYCONSTRUCTOR_H_
+#endif /* FORTRAN_RUNTIME_ARRAY_CONSTRUCTOR_H_ */
diff --git a/FortranRuntime/include/flang/Runtime/assign.h b/FortranRuntime/include/flang/Runtime/assign.h
index a1cc9eaf4355f6..55d15a5c046868 100644
--- a/FortranRuntime/include/flang/Runtime/assign.h
+++ b/FortranRuntime/include/flang/Runtime/assign.h
@@ -58,4 +58,4 @@ void RTDECL(AssignPolymorphic)(Descriptor &to, const Descriptor &from,
     const char *sourceFile = nullptr, int sourceLine = 0);
 } // extern "C"
 } // namespace Fortran::runtime
-#endif // FORTRAN_RUNTIME_ASSIGN_H_
+#endif /* FORTRAN_RUNTIME_ASSIGN_H_ */
diff --git a/FortranRuntime/include/flang/Runtime/c-or-cpp.h b/FortranRuntime/include/flang/Runtime/c-or-cpp.h
index 8bac523907750c..3c0c0be643cbc3 100644
--- a/FortranRuntime/include/flang/Runtime/c-or-cpp.h
+++ b/FortranRuntime/include/flang/Runtime/c-or-cpp.h
@@ -28,4 +28,4 @@
 #define NORETURN IF_CPLUSPLUS([[noreturn]])
 #define NO_ARGUMENTS IF_NOT_CPLUSPLUS(void)
 
-#endif // FORTRAN_RUNTIME_C_OR_CPP_H_
+#endif /* FORTRAN_RUNTIME_C_OR_CPP_H_ */
diff --git a/FortranRuntime/include/flang/Runtime/character.h b/FortranRuntime/include/flang/Runtime/character.h
index dd47686fe858fd..a842c30cd8120c 100644
--- a/FortranRuntime/include/flang/Runtime/character.h
+++ b/FortranRuntime/include/flang/Runtime/character.h
@@ -129,4 +129,4 @@ void RTDECL(Verify)(Descriptor &result, const Descriptor &string,
     const char *sourceFile = nullptr, int sourceLine = 0);
 }
 } // namespace Fortran::runtime
-#endif // FORTRAN_RUNTIME_CHARACTER_H_
+#endif /* FORTRAN_RUNTIME_CHARACTER_H_ */
diff --git a/FortranRuntime/include/flang/Runtime/command.h b/FortranRuntime/include/flang/Runtime/command.h
index 7ab3f6442dcf92..2bbdfca7631163 100644
--- a/FortranRuntime/include/flang/Runtime/command.h
+++ b/FortranRuntime/include/flang/Runtime/command.h
@@ -62,4 +62,4 @@ std::int32_t RTNAME(GetCwd)(
 }
 } // namespace Fortran::runtime
 
-#endif // FORTRAN_RUNTIME_COMMAND_H_
+#endif /* FORTRAN_RUNTIME_COMMAND_H_ */
diff --git a/FortranRuntime/include/flang/Runtime/cpp-type.h b/FortranRuntime/include/flang/Runtime/cpp-type.h
index 27b43de7d0f0f6..7de1ea4f45f224 100644
--- a/FortranRuntime/include/flang/Runtime/cpp-type.h
+++ b/FortranRuntime/include/flang/Runtime/cpp-type.h
@@ -110,4 +110,4 @@ template <> struct CppTypeForHelper<TypeCategory::Logical, 1> {
 };
 
 } // namespace Fortran::runtime
-#endif // FORTRAN_RUNTIME_CPP_TYPE_H_
+#endif /* FORTRAN_RUNTIME_CPP_TYPE_H_ */
diff --git a/FortranRuntime/include/flang/Runtime/derived-api.h b/FortranRuntime/include/flang/Runtime/derived-api.h
index 79aa7d82de8819..ca1681e974051c 100644
--- a/FortranRuntime/include/flang/Runtime/derived-api.h
+++ b/FortranRuntime/include/flang/Runtime/derived-api.h
@@ -63,4 +63,4 @@ bool RTDECL(ExtendsTypeOf)(const Descriptor &, const Descriptor &);
 
 } // extern "C"
 } // namespace Fortran::runtime
-#endif // FORTRAN_RUNTIME_DERIVED_API_H_
+#endif /* FORTRAN_RUNTIME_DERIVED_API_H_ */
diff --git a/FortranRuntime/include/flang/Runtime/descriptor.h b/FortranRuntime/include/flang/Runtime/descriptor.h
index 2fe5b11200cf6d..867f4d4ee29ac0 100644
--- a/FortranRuntime/include/flang/Runtime/descriptor.h
+++ b/FortranRuntime/include/flang/Runtime/descriptor.h
@@ -492,4 +492,4 @@ class alignas(Descriptor) StaticDescriptor {
 };
 
 } // namespace Fortran::runtime
-#endif // FORTRAN_RUNTIME_DESCRIPTOR_H_
+#endif /* FORTRAN_RUNTIME_DESCRIPTOR_H_ */
diff --git a/FortranRuntime/include/flang/Runtime/entry-names.h b/FortranRuntime/include/flang/Runtime/entry-names.h
index 52de2496d9421d..25134771bf9185 100644
--- a/FortranRuntime/include/flang/Runtime/entry-names.h
+++ b/FortranRuntime/include/flang/Runtime/entry-names.h
@@ -15,8 +15,8 @@
  * The value of REVISION should not be changed until/unless the API to the
  * runtime library must change in some way that breaks backward compatibility.
  */
-#ifndef FORTRAN_RUNTIME_ENTRY_NAMES_H
-#define FORTRAN_RUNTIME_ENTRY_NAMES_H
+#ifndef FORTRAN_RUNTIME_ENTRY_NAMES_H_
+#define FORTRAN_RUNTIME_ENTRY_NAMES_H_
 
 #include "flang/Common/api-attrs.h"
 
@@ -40,4 +40,4 @@
 #define RTNAME_STRING(name) RTNAME_STRINGIFY(RTNAME(name))
 #endif
 
-#endif /* !FORTRAN_RUNTIME_ENTRY_NAMES_H */
+#endif /* FORTRAN_RUNTIME_ENTRY_NAMES_H_ */
diff --git a/FortranRuntime/include/flang/Runtime/exceptions.h b/FortranRuntime/include/flang/Runtime/exceptions.h
index 1fb74e14e54d30..f2c67325b34d92 100644
--- a/FortranRuntime/include/flang/Runtime/exceptions.h
+++ b/FortranRuntime/include/flang/Runtime/exceptions.h
@@ -26,4 +26,4 @@ std::uint32_t RTNAME(MapException)(std::uint32_t excepts);
 
 } // extern "C"
 } // namespace Fortran::runtime
-#endif // FORTRAN_RUNTIME_EXCEPTIONS_H_
+#endif /* FORTRAN_RUNTIME_EXCEPTIONS_H_ */
diff --git a/FortranRuntime/include/flang/Runtime/execute.h b/FortranRuntime/include/flang/Runtime/execute.h
index ba3e950ca92941..d1958a82594ffd 100644
--- a/FortranRuntime/include/flang/Runtime/execute.h
+++ b/FortranRuntime/include/flang/Runtime/execute.h
@@ -26,4 +26,4 @@ void RTNAME(ExecuteCommandLine)(const Descriptor &command, bool wait = true,
 }
 } // namespace Fortran::runtime
 
-#endif // FORTRAN_RUNTIME_EXECUTE_H_
+#endif /* FORTRAN_RUNTIME_EXECUTE_H_ */
diff --git a/FortranRuntime/include/flang/Runtime/extensions.h b/FortranRuntime/include/flang/Runtime/extensions.h
index fef651f3b2eedb..f46ccdd7d9528d 100644
--- a/FortranRuntime/include/flang/Runtime/extensions.h
+++ b/FortranRuntime/include/flang/Runtime/extensions.h
@@ -52,4 +52,4 @@ std::int64_t FORTRAN_PROCEDURE_NAME(access)(const char *name,
 #endif
 
 } // extern "C"
-#endif // FORTRAN_RUNTIME_EXTENSIONS_H_
+#endif /* FORTRAN_RUNTIME_EXTENSIONS_H_ */
diff --git a/FortranRuntime/include/flang/Runtime/freestanding-tools.h b/FortranRuntime/include/flang/Runtime/freestanding-tools.h
index e94cb0a6c938cd..8aeef54ba0af3d 100644
--- a/FortranRuntime/include/flang/Runtime/freestanding-tools.h
+++ b/FortranRuntime/include/flang/Runtime/freestanding-tools.h
@@ -215,4 +215,4 @@ using std::toupper;
 #endif // !STD_TOUPPER_UNSUPPORTED
 
 } // namespace Fortran::runtime
-#endif // FORTRAN_RUNTIME_FREESTANDING_TOOLS_H_
+#endif /* FORTRAN_RUNTIME_FREESTANDING_TOOLS_H_ */
diff --git a/FortranRuntime/include/flang/Runtime/inquiry.h b/FortranRuntime/include/flang/Runtime/inquiry.h
index 36ef929ed5b2f1..83b07cf2f31a47 100644
--- a/FortranRuntime/include/flang/Runtime/inquiry.h
+++ b/FortranRuntime/include/flang/Runtime/inquiry.h
@@ -40,4 +40,4 @@ void RTDECL(Ubound)(void *result, const Descriptor &array, int kind,
 
 } // extern "C"
 } // namespace Fortran::runtime
-#endif // FORTRAN_RUNTIME_INQUIRY_H_
+#endif /* FORTRAN_RUNTIME_INQUIRY_H_ */
diff --git a/FortranRuntime/include/flang/Runtime/io-api.h b/FortranRuntime/include/flang/Runtime/io-api.h
index 328afc715a3f1e..367146a4925c53 100644
--- a/FortranRuntime/include/flang/Runtime/io-api.h
+++ b/FortranRuntime/include/flang/Runtime/io-api.h
@@ -369,4 +369,4 @@ enum Iostat IODECL(EndIoStatement)(Cookie);
 
 } // extern "C"
 } // namespace Fortran::runtime::io
-#endif
+#endif /* FORTRAN_RUNTIME_IO_API_H_ */
diff --git a/FortranRuntime/include/flang/Runtime/iostat.h b/FortranRuntime/include/flang/Runtime/iostat.h
index 6ce7c82b424eb7..a5a2a560f05f8d 100644
--- a/FortranRuntime/include/flang/Runtime/iostat.h
+++ b/FortranRuntime/include/flang/Runtime/iostat.h
@@ -92,4 +92,4 @@ enum Iostat {
 RT_API_ATTRS const char *IostatErrorString(int);
 
 } // namespace Fortran::runtime::io
-#endif // FORTRAN_RUNTIME_IOSTAT_H_
+#endif /* FORTRAN_RUNTIME_IOSTAT_H_ */
diff --git a/FortranRuntime/include/flang/Runtime/main.h b/FortranRuntime/include/flang/Runtime/main.h
index 88232ea64fa6ab..98fcf1250d0ad6 100644
--- a/FortranRuntime/include/flang/Runtime/main.h
+++ b/FortranRuntime/include/flang/Runtime/main.h
@@ -20,4 +20,4 @@ void RTNAME(ProgramStart)(
 void RTNAME(ByteswapOption)(void); // -byteswapio
 FORTRAN_EXTERN_C_END
 
-#endif // FORTRAN_RUNTIME_MAIN_H_
+#endif /* FORTRAN_RUNTIME_MAIN_H_ */
diff --git a/FortranRuntime/include/flang/Runtime/matmul-transpose.h b/FortranRuntime/include/flang/Runtime/matmul-transpose.h
index 2d79ca10e08958..077277fae2da86 100644
--- a/FortranRuntime/include/flang/Runtime/matmul-transpose.h
+++ b/FortranRuntime/include/flang/Runtime/matmul-transpose.h
@@ -46,4 +46,4 @@ void RTDECL(MatmulTransposeDirect)(const Descriptor &, const Descriptor &,
 
 } // extern "C"
 } // namespace Fortran::runtime
-#endif // FORTRAN_RUNTIME_MATMUL_TRANSPOSE_H_
+#endif /* FORTRAN_RUNTIME_MATMUL_TRANSPOSE_H_ */
diff --git a/FortranRuntime/include/flang/Runtime/matmul.h b/FortranRuntime/include/flang/Runtime/matmul.h
index a72d4a06ee4594..cd375ac43d77f2 100644
--- a/FortranRuntime/include/flang/Runtime/matmul.h
+++ b/FortranRuntime/include/flang/Runtime/matmul.h
@@ -45,4 +45,4 @@ void RTDECL(MatmulDirect)(const Descriptor &, const Descriptor &,
 
 } // extern "C"
 } // namespace Fortran::runtime
-#endif // FORTRAN_RUNTIME_MATMUL_H_
+#endif /* FORTRAN_RUNTIME_MATMUL_H_ */
diff --git a/FortranRuntime/include/flang/Runtime/memory.h b/FortranRuntime/include/flang/Runtime/memory.h
index 98412a989f890b..84af4d7189c074 100644
--- a/FortranRuntime/include/flang/Runtime/memory.h
+++ b/FortranRuntime/include/flang/Runtime/memory.h
@@ -170,4 +170,4 @@ template <typename A> struct Allocator {
 };
 } // namespace Fortran::runtime
 
-#endif // FORTRAN_RUNTIME_MEMORY_H_
+#endif /* FORTRAN_RUNTIME_MEMORY_H_ */
diff --git a/FortranRuntime/include/flang/Runtime/misc-intrinsic.h b/FortranRuntime/include/flang/Runtime/misc-intrinsic.h
index 3fb3aaed49c0fb..1d4163c2e1e751 100644
--- a/FortranRuntime/include/flang/Runtime/misc-intrinsic.h
+++ b/FortranRuntime/include/flang/Runtime/misc-intrinsic.h
@@ -28,4 +28,4 @@ void RTDECL(TransferSize)(Descriptor &result, const Descriptor &source,
     std::int64_t size);
 } // extern "C"
 } // namespace Fortran::runtime
-#endif // FORTRAN_RUNTIME_MISC_INTRINSIC_H_
+#endif /* FORTRAN_RUNTIME_MISC_INTRINSIC_H_ */
diff --git a/FortranRuntime/include/flang/Runtime/numeric.h b/FortranRuntime/include/flang/Runtime/numeric.h
index 84a5a7cd7a361c..5fbab2e069b739 100644
--- a/FortranRuntime/include/flang/Runtime/numeric.h
+++ b/FortranRuntime/include/flang/Runtime/numeric.h
@@ -455,4 +455,4 @@ CppTypeFor<TypeCategory::Real, 16> RTDECL(FPow16k)(
 
 } // extern "C"
 } // namespace Fortran::runtime
-#endif // FORTRAN_RUNTIME_NUMERIC_H_
+#endif /* FORTRAN_RUNTIME_NUMERIC_H_ */
diff --git a/FortranRuntime/include/flang/Runtime/pointer.h b/FortranRuntime/include/flang/Runtime/pointer.h
index 704144f08114f2..b7322ad92bd583 100644
--- a/FortranRuntime/include/flang/Runtime/pointer.h
+++ b/FortranRuntime/include/flang/Runtime/pointer.h
@@ -122,4 +122,4 @@ RT_API_ATTRS bool ValidatePointerPayload(const ISO::CFI_cdesc_t &);
 
 } // extern "C"
 } // namespace Fortran::runtime
-#endif // FORTRAN_RUNTIME_POINTER_H_
+#endif /* FORTRAN_RUNTIME_POINTER_H_ */
diff --git a/FortranRuntime/include/flang/Runtime/ragged.h b/FortranRuntime/include/flang/Runtime/ragged.h
index ff157ea16f081e..8574bc1fa110c8 100644
--- a/FortranRuntime/include/flang/Runtime/ragged.h
+++ b/FortranRuntime/include/flang/Runtime/ragged.h
@@ -57,4 +57,4 @@ void RTDECL(RaggedArrayDeallocate)(void *raggedArrayHeader);
 
 } // extern "C"
 } // namespace Fortran::runtime
-#endif // FORTRAN_RUNTIME_RAGGED_H_
+#endif /* FORTRAN_RUNTIME_RAGGED_H_ */
diff --git a/FortranRuntime/include/flang/Runtime/random.h b/FortranRuntime/include/flang/Runtime/random.h
index 269297dff47dba..bb6dcb3873f21d 100644
--- a/FortranRuntime/include/flang/Runtime/random.h
+++ b/FortranRuntime/include/flang/Runtime/random.h
@@ -8,6 +8,9 @@
 
 // Intrinsic subroutines RANDOM_INIT, RANDOM_NUMBER, and RANDOM_SEED.
 
+#ifndef FORTRAN_RUNTIME_RANDOM_H_
+#define FORTRAN_RUNTIME_RANDOM_H_
+
 #include "flang/Runtime/entry-names.h"
 #include <cstdint>
 
@@ -35,3 +38,5 @@ void RTNAME(RandomSeed)(const Descriptor *size, const Descriptor *put,
 
 } // extern "C"
 } // namespace Fortran::runtime
+
+#endif /* FORTRAN_RUNTIME_RANDOM_H_ */
diff --git a/FortranRuntime/include/flang/Runtime/reduce.h b/FortranRuntime/include/flang/Runtime/reduce.h
index 60f54c393b4bbd..ae2828f04bf7c0 100644
--- a/FortranRuntime/include/flang/Runtime/reduce.h
+++ b/FortranRuntime/include/flang/Runtime/reduce.h
@@ -435,4 +435,4 @@ void RTDECL(ReduceDerivedTypeDim)(Descriptor &result, const Descriptor &array,
 
 } // extern "C"
 } // namespace Fortran::runtime
-#endif // FORTRAN_RUNTIME_REDUCE_H_
+#endif /* FORTRAN_RUNTIME_REDUCE_H_ */
diff --git a/FortranRuntime/include/flang/Runtime/reduction.h b/FortranRuntime/include/flang/Runtime/reduction.h
index 97986c12e8a10e..e00593fbc9f75e 100644
--- a/FortranRuntime/include/flang/Runtime/reduction.h
+++ b/FortranRuntime/include/flang/Runtime/reduction.h
@@ -444,4 +444,4 @@ bool RTDECL(DotProductLogical)(const Descriptor &, const Descriptor &,
 
 } // extern "C"
 } // namespace Fortran::runtime
-#endif // FORTRAN_RUNTIME_REDUCTION_H_
+#endif /* FORTRAN_RUNTIME_REDUCTION_H_ */
diff --git a/FortranRuntime/include/flang/Runtime/stop.h b/FortranRuntime/include/flang/Runtime/stop.h
index f7c4ffe7403e8e..9ba41343c6f964 100644
--- a/FortranRuntime/include/flang/Runtime/stop.h
+++ b/FortranRuntime/include/flang/Runtime/stop.h
@@ -37,4 +37,4 @@ NORETURN void RTNAME(ReportFatalUserError)(
 
 FORTRAN_EXTERN_C_END
 
-#endif // FORTRAN_RUNTIME_STOP_H_
+#endif /* FORTRAN_RUNTIME_STOP_H_ */
diff --git a/FortranRuntime/include/flang/Runtime/support.h b/FortranRuntime/include/flang/Runtime/support.h
index 4a6d4357e87103..9c9b067a18f2e4 100644
--- a/FortranRuntime/include/flang/Runtime/support.h
+++ b/FortranRuntime/include/flang/Runtime/support.h
@@ -47,4 +47,4 @@ void RTDECL(CopyAndUpdateDescriptor)(Descriptor &to, const Descriptor &from,
 
 } // extern "C"
 } // namespace Fortran::runtime
-#endif // FORTRAN_RUNTIME_SUPPORT_H_
+#endif /* FORTRAN_RUNTIME_SUPPORT_H_ */
diff --git a/FortranRuntime/include/flang/Runtime/temporary-stack.h b/FortranRuntime/include/flang/Runtime/temporary-stack.h
index 3c1a4ea11a4352..f83fab7b0ac811 100644
--- a/FortranRuntime/include/flang/Runtime/temporary-stack.h
+++ b/FortranRuntime/include/flang/Runtime/temporary-stack.h
@@ -64,4 +64,4 @@ void RTNAME(DestroyDescriptorStack)(void *opaquePtr);
 } // extern "C"
 } // namespace Fortran::runtime
 
-#endif // FORTRAN_RUNTIME_TEMPORARY_STACK_H_
+#endif /* FORTRAN_RUNTIME_TEMPORARY_STACK_H_ */
diff --git a/FortranRuntime/include/flang/Runtime/time-intrinsic.h b/FortranRuntime/include/flang/Runtime/time-intrinsic.h
index 80490a17e45597..0e63fc6a4647a4 100644
--- a/FortranRuntime/include/flang/Runtime/time-intrinsic.h
+++ b/FortranRuntime/include/flang/Runtime/time-intrinsic.h
@@ -48,4 +48,4 @@ void RTNAME(Etime)(const Descriptor *values, const Descriptor *time,
 
 } // extern "C"
 } // namespace Fortran::runtime
-#endif // FORTRAN_RUNTIME_TIME_INTRINSIC_H_
+#endif /* FORTRAN_RUNTIME_TIME_INTRINSIC_H_ */
diff --git a/FortranRuntime/include/flang/Runtime/transformational.h b/FortranRuntime/include/flang/Runtime/transformational.h
index a39b872f376a69..266dd9d7aebc24 100644
--- a/FortranRuntime/include/flang/Runtime/transformational.h
+++ b/FortranRuntime/include/flang/Runtime/transformational.h
@@ -154,4 +154,4 @@ void RTDECL(Unpack)(Descriptor &result, const Descriptor &vector,
 
 } // extern "C"
 } // namespace Fortran::runtime
-#endif // FORTRAN_RUNTIME_TRANSFORMATIONAL_H_
+#endif /* FORTRAN_RUNTIME_TRANSFORMATIONAL_H_ */
diff --git a/FortranRuntime/include/flang/Runtime/type-code.h b/FortranRuntime/include/flang/Runtime/type-code.h
index 3c1b03dfaa1140..ec359f25dbdd12 100644
--- a/FortranRuntime/include/flang/Runtime/type-code.h
+++ b/FortranRuntime/include/flang/Runtime/type-code.h
@@ -10,8 +10,8 @@
 #define FORTRAN_RUNTIME_TYPE_CODE_H_
 
 #include "flang/Common/Fortran-consts.h"
-#include "flang/Common/optional.h"
 #include "flang/Common/ISO_Fortran_binding_wrapper.h"
+#include "flang/Common/optional.h"
 #include <utility>
 
 namespace Fortran::runtime {
@@ -75,4 +75,4 @@ class TypeCode {
   ISO::CFI_type_t raw_{CFI_type_other};
 };
 } // namespace Fortran::runtime
-#endif // FORTRAN_RUNTIME_TYPE_CODE_H_
+#endif /* FORTRAN_RUNTIME_TYPE_CODE_H_ */
diff --git a/FortranRuntime/include/flang/Testing/fp-testing.h b/FortranRuntime/include/flang/Testing/fp-testing.h
index 16c6017e8529d5..e223d2ef7d1b8b 100644
--- a/FortranRuntime/include/flang/Testing/fp-testing.h
+++ b/FortranRuntime/include/flang/Testing/fp-testing.h
@@ -6,15 +6,15 @@
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef FORTRAN_TEST_EVALUATE_FP_TESTING_H_
-#define FORTRAN_TEST_EVALUATE_FP_TESTING_H_
+#ifndef FORTRAN_TESTING_FP_TESTING_H_
+#define FORTRAN_TESTING_FP_TESTING_H_
 
 #include "flang/Common/target-rounding.h"
 #include <fenv.h>
 
-using Fortran::common::RoundingMode;
 using Fortran::common::RealFlags;
 using Fortran::common::Rounding;
+using Fortran::common::RoundingMode;
 
 class ScopedHostFloatingPointEnvironment {
 public:
@@ -32,4 +32,4 @@ class ScopedHostFloatingPointEnvironment {
 #endif
 };
 
-#endif // FORTRAN_TEST_EVALUATE_FP_TESTING_H_
+#endif /* FORTRAN_TESTING_FP_TESTING_H_ */
diff --git a/FortranRuntime/include/flang/Testing/testing.h b/FortranRuntime/include/flang/Testing/testing.h
index d763109d62d373..404650c9a89f2c 100644
--- a/FortranRuntime/include/flang/Testing/testing.h
+++ b/FortranRuntime/include/flang/Testing/testing.h
@@ -6,8 +6,8 @@
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef FORTRAN_EVALUATE_TESTING_H_
-#define FORTRAN_EVALUATE_TESTING_H_
+#ifndef FORTRAN_TESTING_TESTING_H_
+#define FORTRAN_TESTING_TESTING_H_
 
 #include <cinttypes>
 #include <string>
@@ -41,4 +41,4 @@ FailureDetailPrinter Match(const char *file, int line, const std::string &want,
 FailureDetailPrinter Compare(const char *file, int line, const char *xs,
     const char *rel, const char *ys, std::uint64_t x, std::uint64_t y);
 } // namespace testing
-#endif // FORTRAN_EVALUATE_TESTING_H_
+#endif /* FORTRAN_TESTING_TESTING_H_ */
diff --git a/FortranRuntime/lib/Common/big-radix-floating-point.h b/FortranRuntime/lib/Common/big-radix-floating-point.h
index 7b8fb03710a3d4..6d247f3796eea5 100644
--- a/FortranRuntime/lib/Common/big-radix-floating-point.h
+++ b/FortranRuntime/lib/Common/big-radix-floating-point.h
@@ -6,8 +6,8 @@
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef FORTRAN_DECIMAL_BIG_RADIX_FLOATING_POINT_H_
-#define FORTRAN_DECIMAL_BIG_RADIX_FLOATING_POINT_H_
+#ifndef FORTRAN_COMMON_BIG_RADIX_FLOATING_POINT_H_
+#define FORTRAN_COMMON_BIG_RADIX_FLOATING_POINT_H_
 
 // This is a helper class for use in floating-point conversions between
 // binary and decimal representations.  It holds a multiple-precision
@@ -21,11 +21,11 @@
 // for conversions between binary and decimal representations; it is not
 // a general-purpose facility.
 
+#include "flang/Common/binary-floating-point.h"
 #include "flang/Common/bit-population-count.h"
+#include "flang/Common/decimal.h"
 #include "flang/Common/leading-zero-bit-count.h"
 #include "flang/Common/uint128.h"
-#include "flang/Common/binary-floating-point.h"
-#include "flang/Common/decimal.h"
 #include <cinttypes>
 #include <limits>
 #include <type_traits>
@@ -393,4 +393,4 @@ template <int PREC, int LOG10RADIX = 16> class BigRadixFloatingPointNumber {
   enum FortranRounding rounding_ { RoundNearest };
 };
 } // namespace Fortran::decimal
-#endif
+#endif /* FORTRAN_COMMON_BIG_RADIX_FLOATING_POINT_H_ */
diff --git a/FortranRuntime/lib/Common/decimal-to-binary.cpp b/FortranRuntime/lib/Common/decimal-to-binary.cpp
index 0ef24d3bcfecfc..cbf1664e9c240d 100644
--- a/FortranRuntime/lib/Common/decimal-to-binary.cpp
+++ b/FortranRuntime/lib/Common/decimal-to-binary.cpp
@@ -7,10 +7,10 @@
 //===----------------------------------------------------------------------===//
 
 #include "big-radix-floating-point.h"
-#include "flang/Common/bit-population-count.h"
-#include "flang/Common/leading-zero-bit-count.h"
 #include "flang/Common/binary-floating-point.h"
+#include "flang/Common/bit-population-count.h"
 #include "flang/Common/decimal.h"
+#include "flang/Common/leading-zero-bit-count.h"
 #include "flang/Runtime/freestanding-tools.h"
 #include <cinttypes>
 #include <cstring>
diff --git a/FortranRuntime/lib/Runtime/CMakeLists.txt b/FortranRuntime/lib/Runtime/CMakeLists.txt
index 3402dd5fe6af8f..9ccbc9ea78b0fc 100644
--- a/FortranRuntime/lib/Runtime/CMakeLists.txt
+++ b/FortranRuntime/lib/Runtime/CMakeLists.txt
@@ -139,21 +139,12 @@ set(supported_files
     "${FLANGRUNTIME_SOURCE_DIR}/include/flang/Common/*.h" 
     )
 
-
   set(private_headers "")
   file(GLOB_RECURSE private_headers 
     "${FLANGRUNTIME_SOURCE_DIR}/lib/Runtime/*.h" 
     "${FLANGRUNTIME_SOURCE_DIR}/lib/Common/*.h" 
     )
 
-
-
-
-
-
-
-
-
 get_target_property(f128_sources
   FortranFloat128MathILib INTERFACE_SOURCES
   )
@@ -170,17 +161,6 @@ if (f128_sources)
   list(APPEND sources ${f128_sources})
 endif()
 
-
-
-
-
-
-
-
-
-
-
-
 if (NOT DEFINED WIN32)
   add_fortranruntime_library(FortranRuntime STATIC
     ${sources}
diff --git a/FortranRuntime/lib/Runtime/CUDA/CMakeLists.txt b/FortranRuntime/lib/Runtime/CUDA/CMakeLists.txt
index f75b854d1eb3ba..81055b2737c0f1 100644
--- a/FortranRuntime/lib/Runtime/CUDA/CMakeLists.txt
+++ b/FortranRuntime/lib/Runtime/CUDA/CMakeLists.txt
@@ -1,4 +1,4 @@
-#===-- lib/Runtime/CUDA/CMakeLists.txt -------------------------------------===#
+#===-- runtime/CUDA/CMakeLists.txt -----------------------------------------===#
 #
 # Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 # See https://llvm.org/LICENSE.txt for license information.
diff --git a/FortranRuntime/lib/Runtime/CUDA/allocator.cpp b/FortranRuntime/lib/Runtime/CUDA/allocator.cpp
index 379f52b45057a0..2efd6bf0a95249 100644
--- a/FortranRuntime/lib/Runtime/CUDA/allocator.cpp
+++ b/FortranRuntime/lib/Runtime/CUDA/allocator.cpp
@@ -11,9 +11,9 @@
 #include "../stat.h"
 #include "../terminator.h"
 #include "../type-info.h"
-#include "flang/Support/Fortran.h"
 #include "flang/ISO_Fortran_binding_wrapper.h"
 #include "flang/Runtime/allocator-registry.h"
+#include "flang/Support/Fortran.h"
 
 #include "cuda_runtime.h"
 
diff --git a/FortranRuntime/lib/Runtime/Float128Math/CMakeLists.txt b/FortranRuntime/lib/Runtime/Float128Math/CMakeLists.txt
index 1ff158c401855f..a5f5bec1e7e4b8 100644
--- a/FortranRuntime/lib/Runtime/Float128Math/CMakeLists.txt
+++ b/FortranRuntime/lib/Runtime/Float128Math/CMakeLists.txt
@@ -1,4 +1,4 @@
-#===-- lib/Runtime/Float128Math/CMakeLists.txt -----------------------------===#
+#===-- runtime/Float128Math/CMakeLists.txt ---------------------------------===#
 #
 # Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 # See https://llvm.org/LICENSE.txt for license information.
diff --git a/FortranRuntime/lib/Runtime/Float128Math/math-entries.h b/FortranRuntime/lib/Runtime/Float128Math/math-entries.h
index 798efdfb1e120c..cb1e0130602260 100644
--- a/FortranRuntime/lib/Runtime/Float128Math/math-entries.h
+++ b/FortranRuntime/lib/Runtime/Float128Math/math-entries.h
@@ -8,10 +8,10 @@
 
 #ifndef FORTRAN_RUNTIME_FLOAT128MATH_MATH_ENTRIES_H_
 #define FORTRAN_RUNTIME_FLOAT128MATH_MATH_ENTRIES_H_
-#include "terminator.h"
-#include "tools.h"
 #include "flang/Common/float128.h"
 #include "flang/Runtime/entry-names.h"
+#include "terminator.h"
+#include "tools.h"
 #include <cfloat>
 #include <cmath>
 #include <type_traits>
@@ -222,4 +222,4 @@ DEFINE_SIMPLE_ALIAS(Yn, ynl)
 
 } // namespace Fortran::runtime
 
-#endif // FORTRAN_RUNTIME_FLOAT128MATH_MATH_ENTRIES_H_
+#endif /* FORTRAN_RUNTIME_FLOAT128MATH_MATH_ENTRIES_H_ */
diff --git a/FortranRuntime/lib/Runtime/Float128Math/numeric-template-specs.h b/FortranRuntime/lib/Runtime/Float128Math/numeric-template-specs.h
index ca9696e18f6a92..2a843df2d1d861 100644
--- a/FortranRuntime/lib/Runtime/Float128Math/numeric-template-specs.h
+++ b/FortranRuntime/lib/Runtime/Float128Math/numeric-template-specs.h
@@ -52,4 +52,4 @@ template <> struct SQRTTy<F128Type> {
 };
 
 } // namespace Fortran::runtime
-#endif // FORTRAN_RUNTIME_FLOAT128MATH_NUMERIC_TEMPLATE_SPECS_H_
+#endif /* FORTRAN_RUNTIME_FLOAT128MATH_NUMERIC_TEMPLATE_SPECS_H_ */
diff --git a/FortranRuntime/lib/Runtime/ISO_Fortran_binding.cpp b/FortranRuntime/lib/Runtime/ISO_Fortran_binding.cpp
index d2fab4bbc30b4d..9711b2bcf49757 100644
--- a/FortranRuntime/lib/Runtime/ISO_Fortran_binding.cpp
+++ b/FortranRuntime/lib/Runtime/ISO_Fortran_binding.cpp
@@ -10,11 +10,11 @@
 // as specified in section 18.5.5 of Fortran 2018.
 
 #include "ISO_Fortran_util.h"
-#include "terminator.h"
 #include "flang/Common/ISO_Fortran_binding_wrapper.h"
 #include "flang/Runtime/descriptor.h"
 #include "flang/Runtime/pointer.h"
 #include "flang/Runtime/type-code.h"
+#include "terminator.h"
 #include <cstdlib>
 
 namespace Fortran::ISO {
diff --git a/FortranRuntime/lib/Runtime/ISO_Fortran_util.h b/FortranRuntime/lib/Runtime/ISO_Fortran_util.h
index c45e8fc7a8d253..7ab280733028af 100644
--- a/FortranRuntime/lib/Runtime/ISO_Fortran_util.h
+++ b/FortranRuntime/lib/Runtime/ISO_Fortran_util.h
@@ -11,10 +11,10 @@
 
 // Internal utils for establishing CFI_cdesc_t descriptors.
 
-#include "terminator.h"
 #include "flang/Common/ISO_Fortran_binding_wrapper.h"
 #include "flang/Runtime/descriptor.h"
 #include "flang/Runtime/type-code.h"
+#include "terminator.h"
 #include <cstdlib>
 
 namespace Fortran::ISO {
@@ -99,4 +99,4 @@ static inline RT_API_ATTRS void EstablishDescriptor(CFI_cdesc_t *descriptor,
   }
 }
 } // namespace Fortran::ISO
-#endif // FORTRAN_RUNTIME_ISO_FORTRAN_UTIL_H_
+#endif /* FORTRAN_RUNTIME_ISO_FORTRAN_UTIL_H_ */
diff --git a/FortranRuntime/lib/Runtime/allocatable.cpp b/FortranRuntime/lib/Runtime/allocatable.cpp
index e3b43a5f813935..8b6c1a4c1477eb 100644
--- a/FortranRuntime/lib/Runtime/allocatable.cpp
+++ b/FortranRuntime/lib/Runtime/allocatable.cpp
@@ -9,12 +9,12 @@
 #include "flang/Runtime/allocatable.h"
 #include "assign-impl.h"
 #include "derived.h"
-#include "stat.h"
-#include "terminator.h"
-#include "type-info.h"
 #include "flang/Common/ISO_Fortran_binding_wrapper.h"
 #include "flang/Runtime/assign.h"
 #include "flang/Runtime/descriptor.h"
+#include "stat.h"
+#include "terminator.h"
+#include "type-info.h"
 
 namespace Fortran::runtime {
 extern "C" {
diff --git a/FortranRuntime/lib/Runtime/array-constructor.cpp b/FortranRuntime/lib/Runtime/array-constructor.cpp
index 287d054887abf0..db57d4fc4c3f68 100644
--- a/FortranRuntime/lib/Runtime/array-constructor.cpp
+++ b/FortranRuntime/lib/Runtime/array-constructor.cpp
@@ -8,12 +8,12 @@
 
 #include "flang/Runtime/array-constructor.h"
 #include "derived.h"
-#include "terminator.h"
-#include "tools.h"
-#include "type-info.h"
 #include "flang/Runtime/allocatable.h"
 #include "flang/Runtime/assign.h"
 #include "flang/Runtime/descriptor.h"
+#include "terminator.h"
+#include "tools.h"
+#include "type-info.h"
 
 namespace Fortran::runtime {
 
diff --git a/FortranRuntime/lib/Runtime/assign-impl.h b/FortranRuntime/lib/Runtime/assign-impl.h
index 6bc8ef78c38a90..d5538fab18b6b5 100644
--- a/FortranRuntime/lib/Runtime/assign-impl.h
+++ b/FortranRuntime/lib/Runtime/assign-impl.h
@@ -21,4 +21,4 @@ RT_API_ATTRS void DoFromSourceAssign(
     Descriptor &, const Descriptor &, Terminator &);
 
 } // namespace Fortran::runtime
-#endif // FORTRAN_RUNTIME_ASSIGN_IMPL_H_
+#endif /* FORTRAN_RUNTIME_ASSIGN_IMPL_H_ */
diff --git a/FortranRuntime/lib/Runtime/assign.cpp b/FortranRuntime/lib/Runtime/assign.cpp
index 7c5eb135d4cfdf..cc38e55e3a9e1e 100644
--- a/FortranRuntime/lib/Runtime/assign.cpp
+++ b/FortranRuntime/lib/Runtime/assign.cpp
@@ -9,11 +9,11 @@
 #include "flang/Runtime/assign.h"
 #include "assign-impl.h"
 #include "derived.h"
+#include "flang/Runtime/descriptor.h"
 #include "stat.h"
 #include "terminator.h"
 #include "tools.h"
 #include "type-info.h"
-#include "flang/Runtime/descriptor.h"
 
 namespace Fortran::runtime {
 
diff --git a/FortranRuntime/lib/Runtime/buffer.h b/FortranRuntime/lib/Runtime/buffer.h
index 24e43734552e99..dd3c19fa14392f 100644
--- a/FortranRuntime/lib/Runtime/buffer.h
+++ b/FortranRuntime/lib/Runtime/buffer.h
@@ -11,9 +11,9 @@
 #ifndef FORTRAN_RUNTIME_BUFFER_H_
 #define FORTRAN_RUNTIME_BUFFER_H_
 
-#include "io-error.h"
 #include "flang/Runtime/freestanding-tools.h"
 #include "flang/Runtime/memory.h"
+#include "io-error.h"
 #include <algorithm>
 #include <cinttypes>
 #include <cstring>
@@ -221,4 +221,4 @@ template <typename STORE, std::size_t minBuffer = 65536> class FileFrame {
   bool dirty_{false};
 };
 } // namespace Fortran::runtime::io
-#endif // FORTRAN_RUNTIME_BUFFER_H_
+#endif /* FORTRAN_RUNTIME_BUFFER_H_ */
diff --git a/FortranRuntime/lib/Runtime/character.cpp b/FortranRuntime/lib/Runtime/character.cpp
index 73d3d93c5015f6..32fc010c6c04dd 100644
--- a/FortranRuntime/lib/Runtime/character.cpp
+++ b/FortranRuntime/lib/Runtime/character.cpp
@@ -7,13 +7,13 @@
 //===----------------------------------------------------------------------===//
 
 #include "flang/Runtime/character.h"
-#include "terminator.h"
-#include "tools.h"
 #include "flang/Common/bit-population-count.h"
 #include "flang/Common/uint128.h"
 #include "flang/Runtime/character.h"
 #include "flang/Runtime/cpp-type.h"
 #include "flang/Runtime/descriptor.h"
+#include "terminator.h"
+#include "tools.h"
 #include <algorithm>
 #include <cstring>
 
diff --git a/FortranRuntime/lib/Runtime/command.cpp b/FortranRuntime/lib/Runtime/command.cpp
index 50a084714e69a4..dc57758d4f7955 100644
--- a/FortranRuntime/lib/Runtime/command.cpp
+++ b/FortranRuntime/lib/Runtime/command.cpp
@@ -8,10 +8,10 @@
 
 #include "flang/Runtime/command.h"
 #include "environment.h"
+#include "flang/Runtime/descriptor.h"
 #include "stat.h"
 #include "terminator.h"
 #include "tools.h"
-#include "flang/Runtime/descriptor.h"
 #include <cstdlib>
 #include <limits>
 
diff --git a/FortranRuntime/lib/Runtime/complex-reduction.h b/FortranRuntime/lib/Runtime/complex-reduction.h
index 1ca5b9a33c4640..e8e287215b7d97 100644
--- a/FortranRuntime/lib/Runtime/complex-reduction.h
+++ b/FortranRuntime/lib/Runtime/complex-reduction.h
@@ -155,4 +155,4 @@ void RTNAME(ReduceComplex16DimValue)(
     REDUCE_DIM_ARGS(CFloat128ComplexType, CFloat128ComplexType_value_op));
 #endif
 
-#endif // FORTRAN_RUNTIME_COMPLEX_REDUCTION_H_
+#endif /* FORTRAN_RUNTIME_COMPLEX_REDUCTION_H_ */
diff --git a/FortranRuntime/lib/Runtime/connection.h b/FortranRuntime/lib/Runtime/connection.h
index f74e94ff6fb4a3..92a3a9c3860a3e 100644
--- a/FortranRuntime/lib/Runtime/connection.h
+++ b/FortranRuntime/lib/Runtime/connection.h
@@ -8,11 +8,11 @@
 
 // Fortran I/O connection state (abstracted over internal & external units)
 
-#ifndef FORTRAN_RUNTIME_IO_CONNECTION_H_
-#define FORTRAN_RUNTIME_IO_CONNECTION_H_
+#ifndef FORTRAN_RUNTIME_CONNECTION_H_
+#define FORTRAN_RUNTIME_CONNECTION_H_
 
-#include "format.h"
 #include "flang/Common/optional.h"
+#include "format.h"
 #include <cinttypes>
 
 namespace Fortran::runtime::io {
@@ -124,4 +124,4 @@ class SavedPosition {
 };
 
 } // namespace Fortran::runtime::io
-#endif // FORTRAN_RUNTIME_IO_CONNECTION_H_
+#endif /* FORTRAN_RUNTIME_CONNECTION_H_ */
diff --git a/FortranRuntime/lib/Runtime/copy.cpp b/FortranRuntime/lib/Runtime/copy.cpp
index 72a86e3b80a7d5..39c7da45172a43 100644
--- a/FortranRuntime/lib/Runtime/copy.cpp
+++ b/FortranRuntime/lib/Runtime/copy.cpp
@@ -7,11 +7,11 @@
 //===----------------------------------------------------------------------===//
 
 #include "copy.h"
+#include "flang/Runtime/allocatable.h"
+#include "flang/Runtime/descriptor.h"
 #include "stack.h"
 #include "terminator.h"
 #include "type-info.h"
-#include "flang/Runtime/allocatable.h"
-#include "flang/Runtime/descriptor.h"
 #include <cstring>
 
 namespace Fortran::runtime {
diff --git a/FortranRuntime/lib/Runtime/copy.h b/FortranRuntime/lib/Runtime/copy.h
index 6d37b075e74504..f2c5b41718b71c 100644
--- a/FortranRuntime/lib/Runtime/copy.h
+++ b/FortranRuntime/lib/Runtime/copy.h
@@ -22,4 +22,4 @@ RT_API_ATTRS void CopyElement(const Descriptor &to, const SubscriptValue toAt[],
     const Descriptor &from, const SubscriptValue fromAt[], Terminator &);
 
 } // namespace Fortran::runtime
-#endif // FORTRAN_RUNTIME_COPY_H_
+#endif /* FORTRAN_RUNTIME_COPY_H_ */
diff --git a/FortranRuntime/lib/Runtime/derived-api.cpp b/FortranRuntime/lib/Runtime/derived-api.cpp
index 0bcdd45ddbbaec..4b68cdbbed7b2c 100644
--- a/FortranRuntime/lib/Runtime/derived-api.cpp
+++ b/FortranRuntime/lib/Runtime/derived-api.cpp
@@ -8,10 +8,10 @@
 
 #include "flang/Runtime/derived-api.h"
 #include "derived.h"
+#include "flang/Runtime/descriptor.h"
 #include "terminator.h"
 #include "tools.h"
 #include "type-info.h"
-#include "flang/Runtime/descriptor.h"
 
 namespace Fortran::runtime {
 
diff --git a/FortranRuntime/lib/Runtime/derived.cpp b/FortranRuntime/lib/Runtime/derived.cpp
index 04d765211db63b..52bf54d62c8599 100644
--- a/FortranRuntime/lib/Runtime/derived.cpp
+++ b/FortranRuntime/lib/Runtime/derived.cpp
@@ -7,11 +7,11 @@
 //===----------------------------------------------------------------------===//
 
 #include "derived.h"
+#include "flang/Runtime/descriptor.h"
 #include "stat.h"
 #include "terminator.h"
 #include "tools.h"
 #include "type-info.h"
-#include "flang/Runtime/descriptor.h"
 
 namespace Fortran::runtime {
 
diff --git a/FortranRuntime/lib/Runtime/derived.h b/FortranRuntime/lib/Runtime/derived.h
index 27c04c7cc56969..e03e657f01cee9 100644
--- a/FortranRuntime/lib/Runtime/derived.h
+++ b/FortranRuntime/lib/Runtime/derived.h
@@ -40,4 +40,4 @@ RT_API_ATTRS void Destroy(const Descriptor &, bool finalize,
 RT_API_ATTRS bool HasDynamicComponent(const Descriptor &);
 
 } // namespace Fortran::runtime
-#endif // FORTRAN_RUNTIME_DERIVED_H_
+#endif /* FORTRAN_RUNTIME_DERIVED_H_ */
diff --git a/FortranRuntime/lib/Runtime/descriptor-io.h b/FortranRuntime/lib/Runtime/descriptor-io.h
index 58cb091f852596..2ccad0cea70a29 100644
--- a/FortranRuntime/lib/Runtime/descriptor-io.h
+++ b/FortranRuntime/lib/Runtime/descriptor-io.h
@@ -16,15 +16,15 @@
 
 #include "edit-input.h"
 #include "edit-output.h"
+#include "flang/Common/optional.h"
+#include "flang/Common/uint128.h"
+#include "flang/Runtime/cpp-type.h"
+#include "flang/Runtime/descriptor.h"
 #include "io-stmt.h"
 #include "namelist.h"
 #include "terminator.h"
 #include "type-info.h"
 #include "unit.h"
-#include "flang/Common/optional.h"
-#include "flang/Common/uint128.h"
-#include "flang/Runtime/cpp-type.h"
-#include "flang/Runtime/descriptor.h"
 
 namespace Fortran::runtime::io::descr {
 template <typename A>
@@ -608,4 +608,4 @@ static RT_API_ATTRS bool DescriptorIO(IoStatementState &io,
   return false;
 }
 } // namespace Fortran::runtime::io::descr
-#endif // FORTRAN_RUNTIME_DESCRIPTOR_IO_H_
+#endif /* FORTRAN_RUNTIME_DESCRIPTOR_IO_H_ */
diff --git a/FortranRuntime/lib/Runtime/descriptor.cpp b/FortranRuntime/lib/Runtime/descriptor.cpp
index f064fe3dcc32e9..6756134b06e7b1 100644
--- a/FortranRuntime/lib/Runtime/descriptor.cpp
+++ b/FortranRuntime/lib/Runtime/descriptor.cpp
@@ -9,12 +9,12 @@
 #include "flang/Runtime/descriptor.h"
 #include "ISO_Fortran_util.h"
 #include "derived.h"
+#include "flang/Runtime/allocator-registry.h"
 #include "memory.h"
 #include "stat.h"
 #include "terminator.h"
 #include "tools.h"
 #include "type-info.h"
-#include "flang/Runtime/allocator-registry.h"
 #include <cassert>
 #include <cstdlib>
 #include <cstring>
diff --git a/FortranRuntime/lib/Runtime/dot-product.cpp b/FortranRuntime/lib/Runtime/dot-product.cpp
index 9eb22790e38a69..ab1cfa58ef3d02 100644
--- a/FortranRuntime/lib/Runtime/dot-product.cpp
+++ b/FortranRuntime/lib/Runtime/dot-product.cpp
@@ -6,13 +6,13 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "float.h"
-#include "terminator.h"
-#include "tools.h"
 #include "flang/Common/float128.h"
 #include "flang/Runtime/cpp-type.h"
 #include "flang/Runtime/descriptor.h"
 #include "flang/Runtime/reduction.h"
+#include "float.h"
+#include "terminator.h"
+#include "tools.h"
 #include <cfloat>
 #include <cinttypes>
 
diff --git a/FortranRuntime/lib/Runtime/edit-input.cpp b/FortranRuntime/lib/Runtime/edit-input.cpp
index 6ebb0e7aca4ade..eaa9d0d7e641e7 100644
--- a/FortranRuntime/lib/Runtime/edit-input.cpp
+++ b/FortranRuntime/lib/Runtime/edit-input.cpp
@@ -7,12 +7,12 @@
 //===----------------------------------------------------------------------===//
 
 #include "edit-input.h"
-#include "namelist.h"
-#include "utf.h"
 #include "flang/Common/optional.h"
 #include "flang/Common/real.h"
 #include "flang/Common/uint128.h"
 #include "flang/Runtime/freestanding-tools.h"
+#include "namelist.h"
+#include "utf.h"
 #include <algorithm>
 #include <cfenv>
 
diff --git a/FortranRuntime/lib/Runtime/edit-input.h b/FortranRuntime/lib/Runtime/edit-input.h
index 96dc3f561c22a7..2eda81a6d4e11d 100644
--- a/FortranRuntime/lib/Runtime/edit-input.h
+++ b/FortranRuntime/lib/Runtime/edit-input.h
@@ -9,9 +9,9 @@
 #ifndef FORTRAN_RUNTIME_EDIT_INPUT_H_
 #define FORTRAN_RUNTIME_EDIT_INPUT_H_
 
+#include "flang/Common/decimal.h"
 #include "format.h"
 #include "io-stmt.h"
-#include "flang/Common/decimal.h"
 
 namespace Fortran::runtime::io {
 
@@ -50,4 +50,4 @@ extern template RT_API_ATTRS bool EditCharacterInput(
     IoStatementState &, const DataEdit &, char32_t *, std::size_t);
 
 } // namespace Fortran::runtime::io
-#endif // FORTRAN_RUNTIME_EDIT_INPUT_H_
+#endif /* FORTRAN_RUNTIME_EDIT_INPUT_H_ */
diff --git a/FortranRuntime/lib/Runtime/edit-output.cpp b/FortranRuntime/lib/Runtime/edit-output.cpp
index ccaf8085f016fd..1fab7db6d3b187 100644
--- a/FortranRuntime/lib/Runtime/edit-output.cpp
+++ b/FortranRuntime/lib/Runtime/edit-output.cpp
@@ -8,9 +8,9 @@
 
 #include "edit-output.h"
 #include "emit-encoded.h"
-#include "utf.h"
 #include "flang/Common/real.h"
 #include "flang/Common/uint128.h"
+#include "utf.h"
 #include <algorithm>
 
 namespace Fortran::runtime::io {
diff --git a/FortranRuntime/lib/Runtime/edit-output.h b/FortranRuntime/lib/Runtime/edit-output.h
index 7f303020a83a84..cb25b68a35f05b 100644
--- a/FortranRuntime/lib/Runtime/edit-output.h
+++ b/FortranRuntime/lib/Runtime/edit-output.h
@@ -18,10 +18,10 @@
 // Drives the same fast binary-to-decimal formatting templates used
 // in the f18 front-end.
 
+#include "flang/Common/decimal.h"
+#include "flang/Common/uint128.h"
 #include "format.h"
 #include "io-stmt.h"
-#include "flang/Common/uint128.h"
-#include "flang/Common/decimal.h"
 
 namespace Fortran::runtime::io {
 
@@ -138,4 +138,4 @@ extern template class RealOutputEditing<10>;
 extern template class RealOutputEditing<16>;
 
 } // namespace Fortran::runtime::io
-#endif // FORTRAN_RUNTIME_EDIT_OUTPUT_H_
+#endif /* FORTRAN_RUNTIME_EDIT_OUTPUT_H_ */
diff --git a/FortranRuntime/lib/Runtime/emit-encoded.h b/FortranRuntime/lib/Runtime/emit-encoded.h
index f07fcced488435..11163a41720795 100644
--- a/FortranRuntime/lib/Runtime/emit-encoded.h
+++ b/FortranRuntime/lib/Runtime/emit-encoded.h
@@ -114,4 +114,4 @@ RT_API_ATTRS bool EmitRepeated(CONTEXT &to, char ch, std::size_t n) {
 }
 
 } // namespace Fortran::runtime::io
-#endif // FORTRAN_RUNTIME_EMIT_ENCODED_H_
+#endif /* FORTRAN_RUNTIME_EMIT_ENCODED_H_ */
diff --git a/FortranRuntime/lib/Runtime/environment.h b/FortranRuntime/lib/Runtime/environment.h
index 71526d2b85d74c..7d10b3a2b934bf 100644
--- a/FortranRuntime/lib/Runtime/environment.h
+++ b/FortranRuntime/lib/Runtime/environment.h
@@ -9,8 +9,8 @@
 #ifndef FORTRAN_RUNTIME_ENVIRONMENT_H_
 #define FORTRAN_RUNTIME_ENVIRONMENT_H_
 
-#include "flang/Common/optional.h"
 #include "flang/Common/decimal.h"
+#include "flang/Common/optional.h"
 
 struct EnvironmentDefaultList;
 
@@ -64,4 +64,4 @@ RT_OFFLOAD_VAR_GROUP_END
 
 } // namespace Fortran::runtime
 
-#endif // FORTRAN_RUNTIME_ENVIRONMENT_H_
+#endif /* FORTRAN_RUNTIME_ENVIRONMENT_H_ */
diff --git a/FortranRuntime/lib/Runtime/execute.cpp b/FortranRuntime/lib/Runtime/execute.cpp
index 77aac164242612..54f28d052873b4 100644
--- a/FortranRuntime/lib/Runtime/execute.cpp
+++ b/FortranRuntime/lib/Runtime/execute.cpp
@@ -8,10 +8,10 @@
 
 #include "flang/Runtime/execute.h"
 #include "environment.h"
+#include "flang/Runtime/descriptor.h"
 #include "stat.h"
 #include "terminator.h"
 #include "tools.h"
-#include "flang/Runtime/descriptor.h"
 #include <cstdlib>
 #include <errno.h>
 #include <future>
diff --git a/FortranRuntime/lib/Runtime/extensions.cpp b/FortranRuntime/lib/Runtime/extensions.cpp
index e75fa75893a82b..94bfa3059e6b45 100644
--- a/FortranRuntime/lib/Runtime/extensions.cpp
+++ b/FortranRuntime/lib/Runtime/extensions.cpp
@@ -10,12 +10,12 @@
 // extensions that will eventually be implemented in Fortran.
 
 #include "flang/Runtime/extensions.h"
-#include "terminator.h"
-#include "tools.h"
 #include "flang/Runtime/command.h"
 #include "flang/Runtime/descriptor.h"
 #include "flang/Runtime/entry-names.h"
 #include "flang/Runtime/io-api.h"
+#include "terminator.h"
+#include "tools.h"
 #include <chrono>
 #include <cstring>
 #include <ctime>
diff --git a/FortranRuntime/lib/Runtime/extrema.cpp b/FortranRuntime/lib/Runtime/extrema.cpp
index be9da63d7bd6b8..0809cb1d5f2ae2 100644
--- a/FortranRuntime/lib/Runtime/extrema.cpp
+++ b/FortranRuntime/lib/Runtime/extrema.cpp
@@ -10,10 +10,10 @@
 // and shapes and (for MAXLOC & MINLOC) result integer kinds.  Also implements
 // NORM2 using common infrastructure.
 
-#include "reduction-templates.h"
 #include "flang/Common/float128.h"
 #include "flang/Runtime/character.h"
 #include "flang/Runtime/reduction.h"
+#include "reduction-templates.h"
 #include <algorithm>
 #include <cfloat>
 #include <cinttypes>
diff --git a/FortranRuntime/lib/Runtime/file.cpp b/FortranRuntime/lib/Runtime/file.cpp
index 44e3850cdfcb13..b82f1c63e397f9 100644
--- a/FortranRuntime/lib/Runtime/file.cpp
+++ b/FortranRuntime/lib/Runtime/file.cpp
@@ -7,9 +7,9 @@
 //===----------------------------------------------------------------------===//
 
 #include "file.h"
-#include "tools.h"
 #include "flang/Runtime/magic-numbers.h"
 #include "flang/Runtime/memory.h"
+#include "tools.h"
 #include <algorithm>
 #include <cerrno>
 #include <cstring>
diff --git a/FortranRuntime/lib/Runtime/file.h b/FortranRuntime/lib/Runtime/file.h
index 6890cb62d66652..66d62756634b24 100644
--- a/FortranRuntime/lib/Runtime/file.h
+++ b/FortranRuntime/lib/Runtime/file.h
@@ -11,9 +11,9 @@
 #ifndef FORTRAN_RUNTIME_FILE_H_
 #define FORTRAN_RUNTIME_FILE_H_
 
-#include "io-error.h"
 #include "flang/Common/optional.h"
 #include "flang/Runtime/memory.h"
+#include "io-error.h"
 #include <cinttypes>
 
 namespace Fortran::runtime::io {
@@ -113,4 +113,4 @@ RT_API_ATTRS bool MayWrite(const char *path);
 RT_API_ATTRS bool MayReadAndWrite(const char *path);
 RT_API_ATTRS std::int64_t SizeInBytes(const char *path);
 } // namespace Fortran::runtime::io
-#endif // FORTRAN_RUNTIME_FILE_H_
+#endif /* FORTRAN_RUNTIME_FILE_H_ */
diff --git a/FortranRuntime/lib/Runtime/findloc.cpp b/FortranRuntime/lib/Runtime/findloc.cpp
index da5fe0c0a0a467..47c51fbcef4939 100644
--- a/FortranRuntime/lib/Runtime/findloc.cpp
+++ b/FortranRuntime/lib/Runtime/findloc.cpp
@@ -9,9 +9,9 @@
 // Implements FINDLOC for all required operand types and shapes and result
 // integer kinds.
 
-#include "reduction-templates.h"
 #include "flang/Runtime/character.h"
 #include "flang/Runtime/reduction.h"
+#include "reduction-templates.h"
 #include <cinttypes>
 #include <complex>
 
diff --git a/FortranRuntime/lib/Runtime/format-implementation.h b/FortranRuntime/lib/Runtime/format-implementation.h
index 2ed6006c3b2fa0..8d0d0f3376eafc 100644
--- a/FortranRuntime/lib/Runtime/format-implementation.h
+++ b/FortranRuntime/lib/Runtime/format-implementation.h
@@ -12,12 +12,12 @@
 #define FORTRAN_RUNTIME_FORMAT_IMPLEMENTATION_H_
 
 #include "emit-encoded.h"
+#include "flang/Common/decimal.h"
+#include "flang/Common/format.h"
+#include "flang/Runtime/main.h"
 #include "format.h"
 #include "io-stmt.h"
 #include "memory.h"
-#include "flang/Common/format.h"
-#include "flang/Common/decimal.h"
-#include "flang/Runtime/main.h"
 #include <algorithm>
 #include <cstring>
 #include <limits>
@@ -601,4 +601,4 @@ RT_API_ATTRS void FormatControl<CONTEXT>::Finish(Context &context) {
   }
 }
 } // namespace Fortran::runtime::io
-#endif // FORTRAN_RUNTIME_FORMAT_IMPLEMENTATION_H_
+#endif /* FORTRAN_RUNTIME_FORMAT_IMPLEMENTATION_H_ */
diff --git a/FortranRuntime/lib/Runtime/format.h b/FortranRuntime/lib/Runtime/format.h
index b9c6979d1c2c98..3e0807ee452a7e 100644
--- a/FortranRuntime/lib/Runtime/format.h
+++ b/FortranRuntime/lib/Runtime/format.h
@@ -12,11 +12,11 @@
 #define FORTRAN_RUNTIME_FORMAT_H_
 
 #include "environment.h"
-#include "io-error.h"
 #include "flang/Common/Fortran-consts.h"
-#include "flang/Common/optional.h"
 #include "flang/Common/decimal.h"
+#include "flang/Common/optional.h"
 #include "flang/Runtime/freestanding-tools.h"
+#include "io-error.h"
 #include <cinttypes>
 
 namespace Fortran::runtime {
@@ -201,4 +201,4 @@ template <typename CONTEXT> class FormatControl {
   Iteration stack_[maxMaxHeight];
 };
 } // namespace Fortran::runtime::io
-#endif // FORTRAN_RUNTIME_FORMAT_H_
+#endif /* FORTRAN_RUNTIME_FORMAT_H_ */
diff --git a/FortranRuntime/lib/Runtime/inquiry.cpp b/FortranRuntime/lib/Runtime/inquiry.cpp
index 9a5ef0cea210db..172b46037d6c4b 100644
--- a/FortranRuntime/lib/Runtime/inquiry.cpp
+++ b/FortranRuntime/lib/Runtime/inquiry.cpp
@@ -11,9 +11,9 @@
 
 #include "flang/Runtime/inquiry.h"
 #include "copy.h"
+#include "flang/Runtime/descriptor.h"
 #include "terminator.h"
 #include "tools.h"
-#include "flang/Runtime/descriptor.h"
 #include <algorithm>
 
 namespace Fortran::runtime {
diff --git a/FortranRuntime/lib/Runtime/internal-unit.cpp b/FortranRuntime/lib/Runtime/internal-unit.cpp
index 95d371a49ac187..81b937ba63d4b8 100644
--- a/FortranRuntime/lib/Runtime/internal-unit.cpp
+++ b/FortranRuntime/lib/Runtime/internal-unit.cpp
@@ -7,9 +7,9 @@
 //===----------------------------------------------------------------------===//
 
 #include "internal-unit.h"
-#include "io-error.h"
 #include "flang/Runtime/descriptor.h"
 #include "flang/Runtime/freestanding-tools.h"
+#include "io-error.h"
 #include <algorithm>
 #include <type_traits>
 
diff --git a/FortranRuntime/lib/Runtime/internal-unit.h b/FortranRuntime/lib/Runtime/internal-unit.h
index 444bc9ab515994..c4107696810f2b 100644
--- a/FortranRuntime/lib/Runtime/internal-unit.h
+++ b/FortranRuntime/lib/Runtime/internal-unit.h
@@ -8,8 +8,8 @@
 
 // Fortran internal I/O "units"
 
-#ifndef FORTRAN_RUNTIME_IO_INTERNAL_UNIT_H_
-#define FORTRAN_RUNTIME_IO_INTERNAL_UNIT_H_
+#ifndef FORTRAN_RUNTIME_INTERNAL_UNIT_H_
+#define FORTRAN_RUNTIME_INTERNAL_UNIT_H_
 
 #include "connection.h"
 #include "flang/Runtime/descriptor.h"
@@ -56,4 +56,4 @@ template <Direction DIR> class InternalDescriptorUnit : public ConnectionState {
 extern template class InternalDescriptorUnit<Direction::Output>;
 extern template class InternalDescriptorUnit<Direction::Input>;
 } // namespace Fortran::runtime::io
-#endif // FORTRAN_RUNTIME_IO_INTERNAL_UNIT_H_
+#endif /* FORTRAN_RUNTIME_INTERNAL_UNIT_H_ */
diff --git a/FortranRuntime/lib/Runtime/io-api-common.h b/FortranRuntime/lib/Runtime/io-api-common.h
index 9b4c3405b0991e..427666723501a2 100644
--- a/FortranRuntime/lib/Runtime/io-api-common.h
+++ b/FortranRuntime/lib/Runtime/io-api-common.h
@@ -6,15 +6,15 @@
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef FLANG_RUNTIME_IO_API_COMMON_H_
-#define FLANG_RUNTIME_IO_API_COMMON_H_
+#ifndef FORTRAN_RUNTIME_IO_API_COMMON_H_
+#define FORTRAN_RUNTIME_IO_API_COMMON_H_
 
-#include "io-stmt.h"
-#include "terminator.h"
-#include "unit.h"
 #include "flang/Common/api-attrs.h"
 #include "flang/Common/optional.h"
 #include "flang/Runtime/io-api.h"
+#include "io-stmt.h"
+#include "terminator.h"
+#include "unit.h"
 
 namespace Fortran::runtime::io {
 
@@ -94,4 +94,4 @@ RT_API_ATTRS Cookie BeginExternalListIO(
 }
 
 } // namespace Fortran::runtime::io
-#endif // FLANG_RUNTIME_IO_API_COMMON_H_
+#endif /* FORTRAN_RUNTIME_IO_API_COMMON_H_ */
diff --git a/FortranRuntime/lib/Runtime/io-api-minimal.cpp b/FortranRuntime/lib/Runtime/io-api-minimal.cpp
index 6bc262cae78458..683694bd63c068 100644
--- a/FortranRuntime/lib/Runtime/io-api-minimal.cpp
+++ b/FortranRuntime/lib/Runtime/io-api-minimal.cpp
@@ -10,13 +10,13 @@
 // list-directed output (PRINT *) of intrinsic types.
 
 #include "edit-output.h"
+#include "flang/Runtime/io-api.h"
 #include "format.h"
 #include "io-api-common.h"
 #include "io-stmt.h"
 #include "terminator.h"
 #include "tools.h"
 #include "unit.h"
-#include "flang/Runtime/io-api.h"
 
 namespace Fortran::runtime::io {
 RT_EXT_API_GROUP_BEGIN
diff --git a/FortranRuntime/lib/Runtime/io-api.cpp b/FortranRuntime/lib/Runtime/io-api.cpp
index f4a396d4c49a45..102ea26b359111 100644
--- a/FortranRuntime/lib/Runtime/io-api.cpp
+++ b/FortranRuntime/lib/Runtime/io-api.cpp
@@ -18,15 +18,15 @@
 #include "edit-input.h"
 #include "edit-output.h"
 #include "environment.h"
+#include "flang/Common/optional.h"
+#include "flang/Runtime/descriptor.h"
+#include "flang/Runtime/memory.h"
 #include "format.h"
 #include "io-api-common.h"
 #include "io-stmt.h"
 #include "terminator.h"
 #include "tools.h"
 #include "unit.h"
-#include "flang/Common/optional.h"
-#include "flang/Runtime/descriptor.h"
-#include "flang/Runtime/memory.h"
 #include <cstdlib>
 #include <memory>
 
diff --git a/FortranRuntime/lib/Runtime/io-error.cpp b/FortranRuntime/lib/Runtime/io-error.cpp
index 053667462058de..b14a30354d2347 100644
--- a/FortranRuntime/lib/Runtime/io-error.cpp
+++ b/FortranRuntime/lib/Runtime/io-error.cpp
@@ -8,8 +8,8 @@
 
 #include "io-error.h"
 #include "config.h"
-#include "tools.h"
 #include "flang/Runtime/magic-numbers.h"
+#include "tools.h"
 #include <cerrno>
 #include <cstdarg>
 #include <cstdio>
diff --git a/FortranRuntime/lib/Runtime/io-error.h b/FortranRuntime/lib/Runtime/io-error.h
index b03e07567a0607..7388a2134ed0d3 100644
--- a/FortranRuntime/lib/Runtime/io-error.h
+++ b/FortranRuntime/lib/Runtime/io-error.h
@@ -15,9 +15,9 @@
 #ifndef FORTRAN_RUNTIME_IO_ERROR_H_
 #define FORTRAN_RUNTIME_IO_ERROR_H_
 
-#include "terminator.h"
 #include "flang/Runtime/iostat.h"
 #include "flang/Runtime/memory.h"
+#include "terminator.h"
 #include <cinttypes>
 
 namespace Fortran::runtime::io {
@@ -78,4 +78,4 @@ class IoErrorHandler : public Terminator {
 };
 
 } // namespace Fortran::runtime::io
-#endif // FORTRAN_RUNTIME_IO_ERROR_H_
+#endif /* FORTRAN_RUNTIME_IO_ERROR_H_ */
diff --git a/FortranRuntime/lib/Runtime/io-stmt.cpp b/FortranRuntime/lib/Runtime/io-stmt.cpp
index 80c96710eb49ca..5be5d98ace0d8a 100644
--- a/FortranRuntime/lib/Runtime/io-stmt.cpp
+++ b/FortranRuntime/lib/Runtime/io-stmt.cpp
@@ -9,11 +9,11 @@
 #include "io-stmt.h"
 #include "connection.h"
 #include "emit-encoded.h"
+#include "flang/Runtime/memory.h"
 #include "format.h"
 #include "tools.h"
 #include "unit.h"
 #include "utf.h"
-#include "flang/Runtime/memory.h"
 #include <algorithm>
 #include <cstdio>
 #include <cstring>
diff --git a/FortranRuntime/lib/Runtime/io-stmt.h b/FortranRuntime/lib/Runtime/io-stmt.h
index e90e64c8fd1ff3..79a8b28c8aa19f 100644
--- a/FortranRuntime/lib/Runtime/io-stmt.h
+++ b/FortranRuntime/lib/Runtime/io-stmt.h
@@ -13,14 +13,14 @@
 
 #include "connection.h"
 #include "file.h"
-#include "format.h"
-#include "internal-unit.h"
-#include "io-error.h"
 #include "flang/Common/optional.h"
 #include "flang/Common/reference-wrapper.h"
 #include "flang/Common/visit.h"
 #include "flang/Runtime/descriptor.h"
 #include "flang/Runtime/io-api.h"
+#include "format.h"
+#include "internal-unit.h"
+#include "io-error.h"
 #include <flang/Common/variant.h>
 #include <functional>
 #include <type_traits>
@@ -789,4 +789,4 @@ class ErroneousIoStatementState : public IoStatementBase {
 };
 
 } // namespace Fortran::runtime::io
-#endif // FORTRAN_RUNTIME_IO_STMT_H_
+#endif /* FORTRAN_RUNTIME_IO_STMT_H_ */
diff --git a/FortranRuntime/lib/Runtime/lock.h b/FortranRuntime/lib/Runtime/lock.h
index 75c1adb12a8c62..69ff6403736dae 100644
--- a/FortranRuntime/lib/Runtime/lock.h
+++ b/FortranRuntime/lib/Runtime/lock.h
@@ -113,4 +113,4 @@ class CriticalSection {
 };
 } // namespace Fortran::runtime
 
-#endif // FORTRAN_RUNTIME_LOCK_H_
+#endif /* FORTRAN_RUNTIME_LOCK_H_ */
diff --git a/FortranRuntime/lib/Runtime/matmul-transpose.cpp b/FortranRuntime/lib/Runtime/matmul-transpose.cpp
index d493333dfa9877..3b4b487daa335e 100644
--- a/FortranRuntime/lib/Runtime/matmul-transpose.cpp
+++ b/FortranRuntime/lib/Runtime/matmul-transpose.cpp
@@ -21,12 +21,12 @@
 // to use the faster BLAS routines.
 
 #include "flang/Runtime/matmul-transpose.h"
-#include "terminator.h"
-#include "tools.h"
 #include "flang/Common/optional.h"
 #include "flang/Runtime/c-or-cpp.h"
 #include "flang/Runtime/cpp-type.h"
 #include "flang/Runtime/descriptor.h"
+#include "terminator.h"
+#include "tools.h"
 #include <cstring>
 
 namespace {
diff --git a/FortranRuntime/lib/Runtime/matmul.cpp b/FortranRuntime/lib/Runtime/matmul.cpp
index 124369e72886c5..62674316bc6a57 100644
--- a/FortranRuntime/lib/Runtime/matmul.cpp
+++ b/FortranRuntime/lib/Runtime/matmul.cpp
@@ -20,12 +20,12 @@
 // Places where BLAS routines could be called are marked as TODO items.
 
 #include "flang/Runtime/matmul.h"
-#include "terminator.h"
-#include "tools.h"
 #include "flang/Common/optional.h"
 #include "flang/Runtime/c-or-cpp.h"
 #include "flang/Runtime/cpp-type.h"
 #include "flang/Runtime/descriptor.h"
+#include "terminator.h"
+#include "tools.h"
 #include <cstring>
 
 namespace {
diff --git a/FortranRuntime/lib/Runtime/memory.cpp b/FortranRuntime/lib/Runtime/memory.cpp
index 4a811107ca220a..bf2c4cd4a35470 100644
--- a/FortranRuntime/lib/Runtime/memory.cpp
+++ b/FortranRuntime/lib/Runtime/memory.cpp
@@ -7,9 +7,9 @@
 //===----------------------------------------------------------------------===//
 
 #include "flang/Runtime/memory.h"
+#include "flang/Runtime/freestanding-tools.h"
 #include "terminator.h"
 #include "tools.h"
-#include "flang/Runtime/freestanding-tools.h"
 #include <cstdlib>
 
 namespace Fortran::runtime {
diff --git a/FortranRuntime/lib/Runtime/misc-intrinsic.cpp b/FortranRuntime/lib/Runtime/misc-intrinsic.cpp
index b942d762e76ab3..a0f41e4e3f156c 100644
--- a/FortranRuntime/lib/Runtime/misc-intrinsic.cpp
+++ b/FortranRuntime/lib/Runtime/misc-intrinsic.cpp
@@ -7,10 +7,10 @@
 //===----------------------------------------------------------------------===//
 
 #include "flang/Runtime/misc-intrinsic.h"
-#include "terminator.h"
-#include "tools.h"
 #include "flang/Common/optional.h"
 #include "flang/Runtime/descriptor.h"
+#include "terminator.h"
+#include "tools.h"
 #include <algorithm>
 #include <cstdio>
 #include <cstring>
diff --git a/FortranRuntime/lib/Runtime/namelist.cpp b/FortranRuntime/lib/Runtime/namelist.cpp
index e6229d56577568..1c8942fc375c43 100644
--- a/FortranRuntime/lib/Runtime/namelist.cpp
+++ b/FortranRuntime/lib/Runtime/namelist.cpp
@@ -9,8 +9,8 @@
 #include "namelist.h"
 #include "descriptor-io.h"
 #include "emit-encoded.h"
-#include "io-stmt.h"
 #include "flang/Runtime/io-api.h"
+#include "io-stmt.h"
 #include <algorithm>
 #include <cstring>
 #include <limits>
diff --git a/FortranRuntime/lib/Runtime/namelist.h b/FortranRuntime/lib/Runtime/namelist.h
index 4694b3104a9c75..2c4d331ae05e85 100644
--- a/FortranRuntime/lib/Runtime/namelist.h
+++ b/FortranRuntime/lib/Runtime/namelist.h
@@ -11,8 +11,8 @@
 #ifndef FORTRAN_RUNTIME_NAMELIST_H_
 #define FORTRAN_RUNTIME_NAMELIST_H_
 
-#include "non-tbp-dio.h"
 #include "flang/Common/api-attrs.h"
+#include "non-tbp-dio.h"
 
 #include <cstddef>
 
@@ -51,4 +51,4 @@ class NamelistGroup {
 RT_API_ATTRS bool IsNamelistNameOrSlash(IoStatementState &);
 
 } // namespace Fortran::runtime::io
-#endif // FORTRAN_RUNTIME_NAMELIST_H_
+#endif /* FORTRAN_RUNTIME_NAMELIST_H_ */
diff --git a/FortranRuntime/lib/Runtime/non-tbp-dio.h b/FortranRuntime/lib/Runtime/non-tbp-dio.h
index 0a45c96a3f2e25..426d5a92fd37d4 100644
--- a/FortranRuntime/lib/Runtime/non-tbp-dio.h
+++ b/FortranRuntime/lib/Runtime/non-tbp-dio.h
@@ -53,4 +53,4 @@ struct NonTbpDefinedIoTable {
 };
 
 } // namespace Fortran::runtime::io
-#endif // FORTRAN_RUNTIME_NON_TBP_DIO_H_
+#endif /* FORTRAN_RUNTIME_NON_TBP_DIO_H_ */
diff --git a/FortranRuntime/lib/Runtime/numeric-templates.h b/FortranRuntime/lib/Runtime/numeric-templates.h
index 640c6d17c4b580..f0045e8ee36e20 100644
--- a/FortranRuntime/lib/Runtime/numeric-templates.h
+++ b/FortranRuntime/lib/Runtime/numeric-templates.h
@@ -18,10 +18,10 @@
 #ifndef FORTRAN_RUNTIME_NUMERIC_TEMPLATES_H_
 #define FORTRAN_RUNTIME_NUMERIC_TEMPLATES_H_
 
-#include "terminator.h"
-#include "tools.h"
 #include "flang/Common/api-attrs.h"
 #include "flang/Common/float128.h"
+#include "terminator.h"
+#include "tools.h"
 #include <cstdint>
 #include <limits>
 
@@ -465,4 +465,4 @@ template <typename T> inline RT_API_ATTRS T ErfcScaled(T arg) {
 
 } // namespace Fortran::runtime
 
-#endif // FORTRAN_RUNTIME_NUMERIC_TEMPLATES_H_
+#endif /* FORTRAN_RUNTIME_NUMERIC_TEMPLATES_H_ */
diff --git a/FortranRuntime/lib/Runtime/numeric.cpp b/FortranRuntime/lib/Runtime/numeric.cpp
index b0f68a7fc81d29..a3fcfeaa9ee266 100644
--- a/FortranRuntime/lib/Runtime/numeric.cpp
+++ b/FortranRuntime/lib/Runtime/numeric.cpp
@@ -7,10 +7,10 @@
 //===----------------------------------------------------------------------===//
 
 #include "flang/Runtime/numeric.h"
+#include "flang/Common/float128.h"
 #include "numeric-templates.h"
 #include "terminator.h"
 #include "tools.h"
-#include "flang/Common/float128.h"
 #include <cfloat>
 #include <climits>
 #include <cmath>
diff --git a/FortranRuntime/lib/Runtime/product.cpp b/FortranRuntime/lib/Runtime/product.cpp
index e4a6e81bd0c508..8c11bf4144919e 100644
--- a/FortranRuntime/lib/Runtime/product.cpp
+++ b/FortranRuntime/lib/Runtime/product.cpp
@@ -8,9 +8,9 @@
 
 // Implements PRODUCT for all required operand types and shapes.
 
-#include "reduction-templates.h"
 #include "flang/Common/float128.h"
 #include "flang/Runtime/reduction.h"
+#include "reduction-templates.h"
 #include <cfloat>
 #include <cinttypes>
 #include <complex>
diff --git a/FortranRuntime/lib/Runtime/random-templates.h b/FortranRuntime/lib/Runtime/random-templates.h
index 4faca63ba34b9d..801484225bc211 100644
--- a/FortranRuntime/lib/Runtime/random-templates.h
+++ b/FortranRuntime/lib/Runtime/random-templates.h
@@ -9,10 +9,10 @@
 #ifndef FORTRAN_RUNTIME_RANDOM_TEMPLATES_H_
 #define FORTRAN_RUNTIME_RANDOM_TEMPLATES_H_
 
-#include "lock.h"
-#include "numeric-templates.h"
 #include "flang/Common/optional.h"
 #include "flang/Runtime/descriptor.h"
+#include "lock.h"
+#include "numeric-templates.h"
 #include <algorithm>
 #include <random>
 
@@ -85,4 +85,4 @@ inline void Generate(const Descriptor &harvest) {
 
 } // namespace Fortran::runtime::random
 
-#endif // FORTRAN_RUNTIME_RANDOM_TEMPLATES_H_
+#endif /* FORTRAN_RUNTIME_RANDOM_TEMPLATES_H_ */
diff --git a/FortranRuntime/lib/Runtime/random.cpp b/FortranRuntime/lib/Runtime/random.cpp
index 343b0a389fcaf6..8e1561960d48be 100644
--- a/FortranRuntime/lib/Runtime/random.cpp
+++ b/FortranRuntime/lib/Runtime/random.cpp
@@ -10,14 +10,14 @@
 // RANDOM_SEED.
 
 #include "flang/Runtime/random.h"
-#include "lock.h"
-#include "random-templates.h"
-#include "terminator.h"
 #include "flang/Common/float128.h"
 #include "flang/Common/leading-zero-bit-count.h"
 #include "flang/Common/uint128.h"
 #include "flang/Runtime/cpp-type.h"
 #include "flang/Runtime/descriptor.h"
+#include "lock.h"
+#include "random-templates.h"
+#include "terminator.h"
 #include <cmath>
 #include <cstdint>
 #include <limits>
diff --git a/FortranRuntime/lib/Runtime/reduce.cpp b/FortranRuntime/lib/Runtime/reduce.cpp
index c3e7ef74363431..4d33c2a714e5af 100644
--- a/FortranRuntime/lib/Runtime/reduce.cpp
+++ b/FortranRuntime/lib/Runtime/reduce.cpp
@@ -9,10 +9,10 @@
 // REDUCE() implementation
 
 #include "flang/Runtime/reduce.h"
+#include "flang/Runtime/descriptor.h"
 #include "reduction-templates.h"
 #include "terminator.h"
 #include "tools.h"
-#include "flang/Runtime/descriptor.h"
 
 namespace Fortran::runtime {
 
diff --git a/FortranRuntime/lib/Runtime/reduction-templates.h b/FortranRuntime/lib/Runtime/reduction-templates.h
index ba193a9f0e3b9d..30ae641ba7b3ac 100644
--- a/FortranRuntime/lib/Runtime/reduction-templates.h
+++ b/FortranRuntime/lib/Runtime/reduction-templates.h
@@ -21,11 +21,11 @@
 #ifndef FORTRAN_RUNTIME_REDUCTION_TEMPLATES_H_
 #define FORTRAN_RUNTIME_REDUCTION_TEMPLATES_H_
 
+#include "flang/Runtime/cpp-type.h"
+#include "flang/Runtime/descriptor.h"
 #include "numeric-templates.h"
 #include "terminator.h"
 #include "tools.h"
-#include "flang/Runtime/cpp-type.h"
-#include "flang/Runtime/descriptor.h"
 #include <algorithm>
 
 namespace Fortran::runtime {
@@ -412,4 +412,4 @@ template <int KIND> struct Norm2Helper {
 };
 
 } // namespace Fortran::runtime
-#endif // FORTRAN_RUNTIME_REDUCTION_TEMPLATES_H_
+#endif /* FORTRAN_RUNTIME_REDUCTION_TEMPLATES_H_ */
diff --git a/FortranRuntime/lib/Runtime/reduction.cpp b/FortranRuntime/lib/Runtime/reduction.cpp
index 0de7dd07b17a5b..f4e1f2aa6818d5 100644
--- a/FortranRuntime/lib/Runtime/reduction.cpp
+++ b/FortranRuntime/lib/Runtime/reduction.cpp
@@ -14,8 +14,8 @@
 // NORM2, MAXLOC, MINLOC, MAXVAL, and MINVAL are in extrema.cpp.
 
 #include "flang/Runtime/reduction.h"
-#include "reduction-templates.h"
 #include "flang/Runtime/descriptor.h"
+#include "reduction-templates.h"
 #include <cinttypes>
 
 namespace Fortran::runtime {
diff --git a/FortranRuntime/lib/Runtime/stack.h b/FortranRuntime/lib/Runtime/stack.h
index 974ccb9d30b0eb..dc5b6101d3da0f 100644
--- a/FortranRuntime/lib/Runtime/stack.h
+++ b/FortranRuntime/lib/Runtime/stack.h
@@ -10,11 +10,11 @@
 // It is a list based stack with dynamic allocation/deallocation
 // of the list nodes.
 
-#ifndef FORTRAN_RUNTIME_STACK_H
-#define FORTRAN_RUNTIME_STACK_H
+#ifndef FORTRAN_RUNTIME_STACK_H_
+#define FORTRAN_RUNTIME_STACK_H_
 
-#include "terminator.h"
 #include "flang/Runtime/memory.h"
+#include "terminator.h"
 
 namespace Fortran::runtime {
 // Storage for the Stack elements of type T.
@@ -133,4 +133,4 @@ template <typename T, unsigned N = 0> class Stack : public StackStorage<T, N> {
   Terminator &terminator_;
 };
 } // namespace Fortran::runtime
-#endif // FORTRAN_RUNTIME_STACK_H
+#endif /* FORTRAN_RUNTIME_STACK_H_ */
diff --git a/FortranRuntime/lib/Runtime/stat.cpp b/FortranRuntime/lib/Runtime/stat.cpp
index d483f75998a746..01ae922e080865 100644
--- a/FortranRuntime/lib/Runtime/stat.cpp
+++ b/FortranRuntime/lib/Runtime/stat.cpp
@@ -7,9 +7,9 @@
 //===----------------------------------------------------------------------===//
 
 #include "stat.h"
+#include "flang/Runtime/descriptor.h"
 #include "terminator.h"
 #include "tools.h"
-#include "flang/Runtime/descriptor.h"
 
 namespace Fortran::runtime {
 RT_OFFLOAD_API_GROUP_BEGIN
diff --git a/FortranRuntime/lib/Runtime/stat.h b/FortranRuntime/lib/Runtime/stat.h
index 9f56d88f588a1e..eccd69024d726b 100644
--- a/FortranRuntime/lib/Runtime/stat.h
+++ b/FortranRuntime/lib/Runtime/stat.h
@@ -11,8 +11,8 @@
 
 #ifndef FORTRAN_RUNTIME_STAT_H_
 #define FORTRAN_RUNTIME_STAT_H_
-#include "flang/Common/api-attrs.h"
 #include "flang/Common/ISO_Fortran_binding_wrapper.h"
+#include "flang/Common/api-attrs.h"
 #include "flang/Runtime/magic-numbers.h"
 namespace Fortran::runtime {
 
@@ -60,4 +60,4 @@ RT_API_ATTRS int ToErrmsg(const Descriptor *errmsg, int stat); // returns stat
 RT_API_ATTRS int ReturnError(Terminator &, int stat,
     const Descriptor *errmsg = nullptr, bool hasStat = false);
 } // namespace Fortran::runtime
-#endif // FORTRAN_RUNTIME_STAT_H
+#endif /* FORTRAN_RUNTIME_STAT_H_ */
diff --git a/FortranRuntime/lib/Runtime/sum.cpp b/FortranRuntime/lib/Runtime/sum.cpp
index 64982b9fd53690..e33b77e20f0f11 100644
--- a/FortranRuntime/lib/Runtime/sum.cpp
+++ b/FortranRuntime/lib/Runtime/sum.cpp
@@ -12,9 +12,9 @@
 // cancellation on intermediate results by using "Kahan summation"
 // (basically the same as manual "double-double").
 
-#include "reduction-templates.h"
 #include "flang/Common/float128.h"
 #include "flang/Runtime/reduction.h"
+#include "reduction-templates.h"
 #include <cfloat>
 #include <cinttypes>
 #include <complex>
diff --git a/FortranRuntime/lib/Runtime/support.cpp b/FortranRuntime/lib/Runtime/support.cpp
index 1dffa99191bae1..0a39ff24b0cafc 100644
--- a/FortranRuntime/lib/Runtime/support.cpp
+++ b/FortranRuntime/lib/Runtime/support.cpp
@@ -8,8 +8,8 @@
 
 #include "flang/Runtime/support.h"
 #include "ISO_Fortran_util.h"
-#include "type-info.h"
 #include "flang/Runtime/descriptor.h"
+#include "type-info.h"
 
 namespace Fortran::runtime {
 extern "C" {
diff --git a/FortranRuntime/lib/Runtime/temporary-stack.cpp b/FortranRuntime/lib/Runtime/temporary-stack.cpp
index 12fa18586b7421..f944dfb7aa1471 100644
--- a/FortranRuntime/lib/Runtime/temporary-stack.cpp
+++ b/FortranRuntime/lib/Runtime/temporary-stack.cpp
@@ -10,11 +10,11 @@
 // temporaries. For use in HLFIR lowering.
 
 #include "flang/Runtime/temporary-stack.h"
-#include "terminator.h"
 #include "flang/Common/ISO_Fortran_binding_wrapper.h"
 #include "flang/Runtime/assign.h"
 #include "flang/Runtime/descriptor.h"
 #include "flang/Runtime/memory.h"
+#include "terminator.h"
 
 namespace {
 
diff --git a/FortranRuntime/lib/Runtime/terminator.h b/FortranRuntime/lib/Runtime/terminator.h
index 02b3a4c4f066f8..f475658b0eab3d 100644
--- a/FortranRuntime/lib/Runtime/terminator.h
+++ b/FortranRuntime/lib/Runtime/terminator.h
@@ -121,4 +121,4 @@ namespace Fortran::runtime::io {
 RT_API_ATTRS void FlushOutputOnCrash(const Terminator &);
 }
 
-#endif // FORTRAN_RUNTIME_TERMINATOR_H_
+#endif /* FORTRAN_RUNTIME_TERMINATOR_H_ */
diff --git a/FortranRuntime/lib/Runtime/time-intrinsic.cpp b/FortranRuntime/lib/Runtime/time-intrinsic.cpp
index 05f7e4f80f18b6..4b362c90c52f25 100644
--- a/FortranRuntime/lib/Runtime/time-intrinsic.cpp
+++ b/FortranRuntime/lib/Runtime/time-intrinsic.cpp
@@ -9,10 +9,10 @@
 // Implements time-related intrinsic subroutines.
 
 #include "flang/Runtime/time-intrinsic.h"
-#include "terminator.h"
-#include "tools.h"
 #include "flang/Runtime/cpp-type.h"
 #include "flang/Runtime/descriptor.h"
+#include "terminator.h"
+#include "tools.h"
 #include <algorithm>
 #include <cstdint>
 #include <cstdio>
diff --git a/FortranRuntime/lib/Runtime/tools.h b/FortranRuntime/lib/Runtime/tools.h
index b57c7996135913..4058767ca283a9 100644
--- a/FortranRuntime/lib/Runtime/tools.h
+++ b/FortranRuntime/lib/Runtime/tools.h
@@ -9,13 +9,13 @@
 #ifndef FORTRAN_RUNTIME_TOOLS_H_
 #define FORTRAN_RUNTIME_TOOLS_H_
 
-#include "stat.h"
-#include "terminator.h"
 #include "flang/Common/optional.h"
 #include "flang/Runtime/cpp-type.h"
 #include "flang/Runtime/descriptor.h"
 #include "flang/Runtime/freestanding-tools.h"
 #include "flang/Runtime/memory.h"
+#include "stat.h"
+#include "terminator.h"
 #include <cstring>
 #include <functional>
 #include <map>
@@ -535,4 +535,4 @@ RT_API_ATTRS void CreatePartialReductionResult(Descriptor &result,
     const char *intrinsic, TypeCode);
 
 } // namespace Fortran::runtime
-#endif // FORTRAN_RUNTIME_TOOLS_H_
+#endif /* FORTRAN_RUNTIME_TOOLS_H_ */
diff --git a/FortranRuntime/lib/Runtime/transformational.cpp b/FortranRuntime/lib/Runtime/transformational.cpp
index 8c244fc296f3b9..66dc5bd4939bae 100644
--- a/FortranRuntime/lib/Runtime/transformational.cpp
+++ b/FortranRuntime/lib/Runtime/transformational.cpp
@@ -18,10 +18,10 @@
 
 #include "flang/Runtime/transformational.h"
 #include "copy.h"
-#include "terminator.h"
-#include "tools.h"
 #include "flang/Common/float128.h"
 #include "flang/Runtime/descriptor.h"
+#include "terminator.h"
+#include "tools.h"
 
 namespace Fortran::runtime {
 
diff --git a/FortranRuntime/lib/Runtime/type-info.h b/FortranRuntime/lib/Runtime/type-info.h
index 28e7c4696613b3..ff3523bcb2b8eb 100644
--- a/FortranRuntime/lib/Runtime/type-info.h
+++ b/FortranRuntime/lib/Runtime/type-info.h
@@ -12,11 +12,11 @@
 // A C++ perspective of the derived type description schemata in
 // flang/module/__fortran_type_info.f90.
 
-#include "terminator.h"
 #include "flang/Common/Fortran-consts.h"
 #include "flang/Common/bit-population-count.h"
 #include "flang/Common/optional.h"
 #include "flang/Runtime/descriptor.h"
+#include "terminator.h"
 #include <cinttypes>
 #include <memory>
 
@@ -321,4 +321,4 @@ class DerivedType {
 };
 
 } // namespace Fortran::runtime::typeInfo
-#endif // FORTRAN_RUNTIME_TYPE_INFO_H_
+#endif /* FORTRAN_RUNTIME_TYPE_INFO_H_ */
diff --git a/FortranRuntime/lib/Runtime/unit-map.h b/FortranRuntime/lib/Runtime/unit-map.h
index f9f0d34d4f0193..4e61246f9a2d86 100644
--- a/FortranRuntime/lib/Runtime/unit-map.h
+++ b/FortranRuntime/lib/Runtime/unit-map.h
@@ -12,10 +12,10 @@
 #ifndef FORTRAN_RUNTIME_UNIT_MAP_H_
 #define FORTRAN_RUNTIME_UNIT_MAP_H_
 
-#include "lock.h"
-#include "unit.h"
 #include "flang/Common/fast-int-set.h"
 #include "flang/Runtime/memory.h"
+#include "lock.h"
+#include "unit.h"
 #include <cstdint>
 #include <cstdlib>
 
@@ -100,4 +100,4 @@ class UnitMap {
   int emergencyNewUnit_{maxNewUnits_}; // not recycled
 };
 } // namespace Fortran::runtime::io
-#endif // FORTRAN_RUNTIME_UNIT_MAP_H_
+#endif /* FORTRAN_RUNTIME_UNIT_MAP_H_ */
diff --git a/FortranRuntime/lib/Runtime/unit.h b/FortranRuntime/lib/Runtime/unit.h
index 608f3a28ef687d..993fbf2977cebf 100644
--- a/FortranRuntime/lib/Runtime/unit.h
+++ b/FortranRuntime/lib/Runtime/unit.h
@@ -8,21 +8,21 @@
 
 // Fortran external I/O units
 
-#ifndef FORTRAN_RUNTIME_IO_UNIT_H_
-#define FORTRAN_RUNTIME_IO_UNIT_H_
+#ifndef FORTRAN_RUNTIME_UNIT_H_
+#define FORTRAN_RUNTIME_UNIT_H_
 
 #include "buffer.h"
 #include "connection.h"
 #include "environment.h"
 #include "file.h"
+#include "flang/Common/constexpr-bitset.h"
+#include "flang/Common/optional.h"
+#include "flang/Runtime/memory.h"
 #include "format.h"
 #include "io-error.h"
 #include "io-stmt.h"
 #include "lock.h"
 #include "terminator.h"
-#include "flang/Common/constexpr-bitset.h"
-#include "flang/Common/optional.h"
-#include "flang/Runtime/memory.h"
 #include <cstdlib>
 #include <cstring>
 #include <flang/Common/variant.h>
@@ -291,4 +291,4 @@ class ChildIo {
 };
 
 } // namespace Fortran::runtime::io
-#endif // FORTRAN_RUNTIME_IO_UNIT_H_
+#endif /* FORTRAN_RUNTIME_UNIT_H_ */
diff --git a/FortranRuntime/lib/Runtime/utf.h b/FortranRuntime/lib/Runtime/utf.h
index 5ba40437ea0c95..35c03fd4cdded5 100644
--- a/FortranRuntime/lib/Runtime/utf.h
+++ b/FortranRuntime/lib/Runtime/utf.h
@@ -70,4 +70,4 @@ RT_API_ATTRS Fortran::common::optional<char32_t> DecodeUTF8(const char *);
 RT_API_ATTRS std::size_t EncodeUTF8(char *, char32_t);
 
 } // namespace Fortran::runtime
-#endif // FORTRAN_RUNTIME_UTF_H_
+#endif /* FORTRAN_RUNTIME_UTF_H_ */
diff --git a/FortranRuntime/lib/Testing/fp-testing.cpp b/FortranRuntime/lib/Testing/fp-testing.cpp
index 8541b1406334d3..3301d2d8efb15f 100644
--- a/FortranRuntime/lib/Testing/fp-testing.cpp
+++ b/FortranRuntime/lib/Testing/fp-testing.cpp
@@ -1,11 +1,3 @@
-//===-- lib/Testing/fp-testing.cpp ------------------------------*- C++ -*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
 #include "flang/Testing/fp-testing.h"
 #include "llvm/Support/Errno.h"
 #include <cstdio>
diff --git a/FortranRuntime/unittests/Common/FastIntSetTest.cpp b/FortranRuntime/unittests/Common/FastIntSetTest.cpp
index f19359f4097ab8..a36a334e370eb9 100644
--- a/FortranRuntime/unittests/Common/FastIntSetTest.cpp
+++ b/FortranRuntime/unittests/Common/FastIntSetTest.cpp
@@ -6,8 +6,8 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "gtest/gtest.h"
 #include "flang/Common/fast-int-set.h"
+#include "gtest/gtest.h"
 #include <optional>
 
 TEST(FastIntSetTests, Sanity) {
diff --git a/FortranRuntime/unittests/Evaluate/ISO-Fortran-binding.cpp b/FortranRuntime/unittests/Evaluate/ISO-Fortran-binding.cpp
index 97d23ca90e5022..d2546e0c22d2d6 100644
--- a/FortranRuntime/unittests/Evaluate/ISO-Fortran-binding.cpp
+++ b/FortranRuntime/unittests/Evaluate/ISO-Fortran-binding.cpp
@@ -6,9 +6,9 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "flang/Testing/testing.h"
 #include "flang/Common/ISO_Fortran_binding_wrapper.h"
 #include "flang/Runtime/descriptor.h"
+#include "flang/Testing/testing.h"
 #include "llvm/Support/raw_ostream.h"
 #include <type_traits>
 
diff --git a/FortranRuntime/unittests/Evaluate/reshape.cpp b/FortranRuntime/unittests/Evaluate/reshape.cpp
index 82caebe081fcd2..a93afd2a3c90cd 100644
--- a/FortranRuntime/unittests/Evaluate/reshape.cpp
+++ b/FortranRuntime/unittests/Evaluate/reshape.cpp
@@ -6,9 +6,9 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "flang/Testing/testing.h"
 #include "flang/Runtime/descriptor.h"
 #include "flang/Runtime/transformational.h"
+#include "flang/Testing/testing.h"
 #include <cinttypes>
 
 using namespace Fortran::common;
diff --git a/FortranRuntime/unittests/Runtime/AccessTest.cpp b/FortranRuntime/unittests/Runtime/AccessTest.cpp
index e72386cc9ac247..3e9feaf945b66d 100644
--- a/FortranRuntime/unittests/Runtime/AccessTest.cpp
+++ b/FortranRuntime/unittests/Runtime/AccessTest.cpp
@@ -10,9 +10,9 @@
 #ifndef _WIN32
 
 #include "CrashHandlerFixture.h"
-#include "gtest/gtest.h"
 #include "flang/Runtime/extensions.h"
 #include "llvm/ADT/Twine.h"
+#include "gtest/gtest.h"
 
 #include <fcntl.h>
 #include <sys/stat.h>
diff --git a/FortranRuntime/unittests/Runtime/Allocatable.cpp b/FortranRuntime/unittests/Runtime/Allocatable.cpp
index 8e10dc408ceae8..c01f85598d21ed 100644
--- a/FortranRuntime/unittests/Runtime/Allocatable.cpp
+++ b/FortranRuntime/unittests/Runtime/Allocatable.cpp
@@ -7,8 +7,8 @@
 //===----------------------------------------------------------------------===//
 
 #include "flang/Runtime/allocatable.h"
-#include "gtest/gtest.h"
 #include "tools.h"
+#include "gtest/gtest.h"
 
 using namespace Fortran::runtime;
 
diff --git a/FortranRuntime/unittests/Runtime/ArrayConstructor.cpp b/FortranRuntime/unittests/Runtime/ArrayConstructor.cpp
index 8c7fce3e4fb5f7..9011da304b6bc3 100644
--- a/FortranRuntime/unittests/Runtime/ArrayConstructor.cpp
+++ b/FortranRuntime/unittests/Runtime/ArrayConstructor.cpp
@@ -6,13 +6,13 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "gtest/gtest.h"
-#include "tools.h"
 #include "flang/Runtime/allocatable.h"
 #include "flang/Runtime/array-constructor.h"
 #include "flang/Runtime/cpp-type.h"
 #include "flang/Runtime/descriptor.h"
 #include "flang/Runtime/type-code.h"
+#include "tools.h"
+#include "gtest/gtest.h"
 
 #include <memory>
 
diff --git a/FortranRuntime/unittests/Runtime/CUDA/AllocatorCUF.cpp b/FortranRuntime/unittests/Runtime/CUDA/AllocatorCUF.cpp
index 5bafb484236340..d2c1600af8c631 100644
--- a/FortranRuntime/unittests/Runtime/CUDA/AllocatorCUF.cpp
+++ b/FortranRuntime/unittests/Runtime/CUDA/AllocatorCUF.cpp
@@ -6,13 +6,13 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "gtest/gtest.h"
 #include "../../../runtime/terminator.h"
-#include "flang/Support/Fortran.h"
 #include "flang/Runtime/CUDA/allocator.h"
 #include "flang/Runtime/CUDA/descriptor.h"
 #include "flang/Runtime/allocatable.h"
 #include "flang/Runtime/allocator-registry.h"
+#include "flang/Support/Fortran.h"
+#include "gtest/gtest.h"
 
 #include "cuda_runtime.h"
 
diff --git a/FortranRuntime/unittests/Runtime/CharacterTest.cpp b/FortranRuntime/unittests/Runtime/CharacterTest.cpp
index 710c1ca0eee817..8829f5e43265b0 100644
--- a/FortranRuntime/unittests/Runtime/CharacterTest.cpp
+++ b/FortranRuntime/unittests/Runtime/CharacterTest.cpp
@@ -10,8 +10,8 @@
 // in Fortran.
 
 #include "flang/Runtime/character.h"
-#include "gtest/gtest.h"
 #include "flang/Runtime/descriptor.h"
+#include "gtest/gtest.h"
 #include <cstring>
 #include <functional>
 #include <tuple>
diff --git a/FortranRuntime/unittests/Runtime/CommandTest.cpp b/FortranRuntime/unittests/Runtime/CommandTest.cpp
index 03a31ceab8030b..aa79ce381ba8d0 100644
--- a/FortranRuntime/unittests/Runtime/CommandTest.cpp
+++ b/FortranRuntime/unittests/Runtime/CommandTest.cpp
@@ -7,12 +7,12 @@
 //===----------------------------------------------------------------------===//
 
 #include "flang/Runtime/command.h"
-#include "gmock/gmock.h"
-#include "gtest/gtest.h"
 #include "flang/Runtime/descriptor.h"
 #include "flang/Runtime/execute.h"
 #include "flang/Runtime/extensions.h"
 #include "flang/Runtime/main.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
 #include <cstddef>
 #include <cstdlib>
 
diff --git a/FortranRuntime/unittests/Runtime/Complex.cpp b/FortranRuntime/unittests/Runtime/Complex.cpp
index daa4b5c7960842..d714da24dc4e58 100644
--- a/FortranRuntime/unittests/Runtime/Complex.cpp
+++ b/FortranRuntime/unittests/Runtime/Complex.cpp
@@ -1,4 +1,4 @@
-//===-- unittests/Runtime/Complex.cpp ---------------------------*- C++ -*-===//
+//===-- flang/unittests/Runtime/Complex.cpp ---------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/FortranRuntime/unittests/Runtime/CrashHandlerFixture.h b/FortranRuntime/unittests/Runtime/CrashHandlerFixture.h
index af6d8e4cc7d525..46805775af0b39 100644
--- a/FortranRuntime/unittests/Runtime/CrashHandlerFixture.h
+++ b/FortranRuntime/unittests/Runtime/CrashHandlerFixture.h
@@ -10,12 +10,12 @@
 /// with expected message.
 //
 //===----------------------------------------------------------------------===//
-#ifndef LLVM_FLANG_UNITTESTS_RUNTIMEGTEST_CRASHHANDLERFIXTURE_H
-#define LLVM_FLANG_UNITTESTS_RUNTIMEGTEST_CRASHHANDLERFIXTURE_H
+#ifndef FORTRAN_UNITTESTS_RUNTIME_CRASHHANDLERFIXTURE_H_
+#define FORTRAN_UNITTESTS_RUNTIME_CRASHHANDLERFIXTURE_H_
 #include <gtest/gtest.h>
 
 struct CrashHandlerFixture : testing::Test {
   void SetUp();
 };
 
-#endif
+#endif /* FORTRAN_UNITTESTS_RUNTIME_CRASHHANDLERFIXTURE_H_ */
diff --git a/FortranRuntime/unittests/Runtime/Derived.cpp b/FortranRuntime/unittests/Runtime/Derived.cpp
index 8d5471e3e0bcf3..11b732fe10b790 100644
--- a/FortranRuntime/unittests/Runtime/Derived.cpp
+++ b/FortranRuntime/unittests/Runtime/Derived.cpp
@@ -6,10 +6,10 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "gtest/gtest.h"
-#include "tools.h"
 #include "flang/Runtime/derived-api.h"
 #include "flang/Runtime/descriptor.h"
+#include "tools.h"
+#include "gtest/gtest.h"
 
 using namespace Fortran::runtime;
 
diff --git a/FortranRuntime/unittests/Runtime/ExternalIOTest.cpp b/FortranRuntime/unittests/Runtime/ExternalIOTest.cpp
index 23c1e9992c101e..00c2fd76ce0c04 100644
--- a/FortranRuntime/unittests/Runtime/ExternalIOTest.cpp
+++ b/FortranRuntime/unittests/Runtime/ExternalIOTest.cpp
@@ -11,12 +11,12 @@
 //===----------------------------------------------------------------------===//
 
 #include "CrashHandlerFixture.h"
-#include "gtest/gtest.h"
 #include "flang/Runtime/descriptor.h"
 #include "flang/Runtime/io-api.h"
 #include "flang/Runtime/main.h"
 #include "flang/Runtime/stop.h"
 #include "llvm/Support/raw_ostream.h"
+#include "gtest/gtest.h"
 #include <cstring>
 #include <string_view>
 
diff --git a/FortranRuntime/unittests/Runtime/Inquiry.cpp b/FortranRuntime/unittests/Runtime/Inquiry.cpp
index 39303b7c809002..204a97a1088ac0 100644
--- a/FortranRuntime/unittests/Runtime/Inquiry.cpp
+++ b/FortranRuntime/unittests/Runtime/Inquiry.cpp
@@ -7,9 +7,9 @@
 //===----------------------------------------------------------------------===//
 
 #include "flang/Runtime/inquiry.h"
-#include "gtest/gtest.h"
-#include "tools.h"
 #include "flang/Runtime/type-code.h"
+#include "tools.h"
+#include "gtest/gtest.h"
 
 using namespace Fortran::runtime;
 using Fortran::common::TypeCategory;
diff --git a/FortranRuntime/unittests/Runtime/ListInputTest.cpp b/FortranRuntime/unittests/Runtime/ListInputTest.cpp
index 472838c25841c9..4c30d6ed750141 100644
--- a/FortranRuntime/unittests/Runtime/ListInputTest.cpp
+++ b/FortranRuntime/unittests/Runtime/ListInputTest.cpp
@@ -6,8 +6,8 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "CrashHandlerFixture.h"
 #include "../../lib/Runtime/io-error.h"
+#include "CrashHandlerFixture.h"
 #include "flang/Runtime/descriptor.h"
 #include "flang/Runtime/io-api.h"
 
diff --git a/FortranRuntime/unittests/Runtime/Matmul.cpp b/FortranRuntime/unittests/Runtime/Matmul.cpp
index a37b618d3ab11a..cfa5d18cc36d33 100644
--- a/FortranRuntime/unittests/Runtime/Matmul.cpp
+++ b/FortranRuntime/unittests/Runtime/Matmul.cpp
@@ -7,12 +7,12 @@
 //===----------------------------------------------------------------------===//
 
 #include "flang/Runtime/matmul.h"
-#include "gtest/gtest.h"
-#include "tools.h"
 #include "flang/Runtime/allocatable.h"
 #include "flang/Runtime/cpp-type.h"
 #include "flang/Runtime/descriptor.h"
 #include "flang/Runtime/type-code.h"
+#include "tools.h"
+#include "gtest/gtest.h"
 
 using namespace Fortran::runtime;
 using Fortran::common::TypeCategory;
diff --git a/FortranRuntime/unittests/Runtime/MatmulTranspose.cpp b/FortranRuntime/unittests/Runtime/MatmulTranspose.cpp
index 3483d1896e8bf6..146c2283fb1aca 100644
--- a/FortranRuntime/unittests/Runtime/MatmulTranspose.cpp
+++ b/FortranRuntime/unittests/Runtime/MatmulTranspose.cpp
@@ -6,13 +6,13 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "gtest/gtest.h"
-#include "tools.h"
 #include "flang/Runtime/allocatable.h"
 #include "flang/Runtime/cpp-type.h"
 #include "flang/Runtime/descriptor.h"
 #include "flang/Runtime/matmul-transpose.h"
 #include "flang/Runtime/type-code.h"
+#include "tools.h"
+#include "gtest/gtest.h"
 
 using namespace Fortran::runtime;
 using Fortran::common::TypeCategory;
diff --git a/FortranRuntime/unittests/Runtime/MiscIntrinsic.cpp b/FortranRuntime/unittests/Runtime/MiscIntrinsic.cpp
index 5672440c0e1b95..08229b5e48f0dd 100644
--- a/FortranRuntime/unittests/Runtime/MiscIntrinsic.cpp
+++ b/FortranRuntime/unittests/Runtime/MiscIntrinsic.cpp
@@ -6,12 +6,12 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "gtest/gtest.h"
-#include "tools.h"
 #include "flang/Runtime//misc-intrinsic.h"
 #include "flang/Runtime/allocatable.h"
 #include "flang/Runtime/cpp-type.h"
 #include "flang/Runtime/descriptor.h"
+#include "tools.h"
+#include "gtest/gtest.h"
 
 using namespace Fortran::runtime;
 
diff --git a/FortranRuntime/unittests/Runtime/Namelist.cpp b/FortranRuntime/unittests/Runtime/Namelist.cpp
index 729f9ffa5c7c10..7b834dec49c3c4 100644
--- a/FortranRuntime/unittests/Runtime/Namelist.cpp
+++ b/FortranRuntime/unittests/Runtime/Namelist.cpp
@@ -8,9 +8,9 @@
 
 #include "../../lib/Runtime/namelist.h"
 #include "CrashHandlerFixture.h"
-#include "tools.h"
 #include "flang/Runtime/descriptor.h"
 #include "flang/Runtime/io-api.h"
+#include "tools.h"
 #include <algorithm>
 #include <cinttypes>
 #include <complex>
diff --git a/FortranRuntime/unittests/Runtime/Numeric.cpp b/FortranRuntime/unittests/Runtime/Numeric.cpp
index d15919b972bca7..fb595ae262c324 100644
--- a/FortranRuntime/unittests/Runtime/Numeric.cpp
+++ b/FortranRuntime/unittests/Runtime/Numeric.cpp
@@ -7,8 +7,8 @@
 //===----------------------------------------------------------------------===//
 
 #include "flang/Runtime/numeric.h"
-#include "gtest/gtest.h"
 #include "flang/Common/float128.h"
+#include "gtest/gtest.h"
 #include <cmath>
 #include <limits>
 
diff --git a/FortranRuntime/unittests/Runtime/Pointer.cpp b/FortranRuntime/unittests/Runtime/Pointer.cpp
index aa8545cdf951d1..a05bd70a64bb9f 100644
--- a/FortranRuntime/unittests/Runtime/Pointer.cpp
+++ b/FortranRuntime/unittests/Runtime/Pointer.cpp
@@ -7,9 +7,9 @@
 //===----------------------------------------------------------------------===//
 
 #include "flang/Runtime/pointer.h"
-#include "gtest/gtest.h"
-#include "tools.h"
 #include "flang/Runtime/descriptor.h"
+#include "tools.h"
+#include "gtest/gtest.h"
 
 using namespace Fortran::runtime;
 
diff --git a/FortranRuntime/unittests/Runtime/Random.cpp b/FortranRuntime/unittests/Runtime/Random.cpp
index c2300a478832ab..4e4b59cbcf40e7 100644
--- a/FortranRuntime/unittests/Runtime/Random.cpp
+++ b/FortranRuntime/unittests/Runtime/Random.cpp
@@ -7,9 +7,9 @@
 //===----------------------------------------------------------------------===//
 
 #include "flang/Runtime//random.h"
-#include "gtest/gtest.h"
 #include "flang/Runtime/descriptor.h"
 #include "flang/Runtime/type-code.h"
+#include "gtest/gtest.h"
 #include <cmath>
 
 using namespace Fortran::runtime;
diff --git a/FortranRuntime/unittests/Runtime/Reduction.cpp b/FortranRuntime/unittests/Runtime/Reduction.cpp
index e8b5ac878871fd..c35f6e2fa6a41b 100644
--- a/FortranRuntime/unittests/Runtime/Reduction.cpp
+++ b/FortranRuntime/unittests/Runtime/Reduction.cpp
@@ -7,14 +7,14 @@
 //===----------------------------------------------------------------------===//
 
 #include "flang/Runtime/reduction.h"
-#include "gtest/gtest.h"
-#include "tools.h"
 #include "flang/Common/float128.h"
 #include "flang/Runtime/allocatable.h"
 #include "flang/Runtime/cpp-type.h"
 #include "flang/Runtime/descriptor.h"
 #include "flang/Runtime/reduce.h"
 #include "flang/Runtime/type-code.h"
+#include "tools.h"
+#include "gtest/gtest.h"
 #include <cstdint>
 #include <cstring>
 #include <string>
diff --git a/FortranRuntime/unittests/Runtime/RuntimeCrashTest.cpp b/FortranRuntime/unittests/Runtime/RuntimeCrashTest.cpp
index 7ce1ee796d739b..61580a8d46792f 100644
--- a/FortranRuntime/unittests/Runtime/RuntimeCrashTest.cpp
+++ b/FortranRuntime/unittests/Runtime/RuntimeCrashTest.cpp
@@ -10,11 +10,11 @@
 /// runtime components and ensure the test fixture handles crashes as we expect.
 //
 //===----------------------------------------------------------------------===//
-#include "CrashHandlerFixture.h"
-#include "tools.h"
 #include "../../lib/Runtime/terminator.h"
+#include "CrashHandlerFixture.h"
 #include "flang/Runtime/io-api.h"
 #include "flang/Runtime/transformational.h"
+#include "tools.h"
 #include <gtest/gtest.h>
 
 using namespace Fortran::runtime;
diff --git a/FortranRuntime/unittests/Runtime/Stop.cpp b/FortranRuntime/unittests/Runtime/Stop.cpp
index c12ec097068438..5fd8deaad21d6b 100644
--- a/FortranRuntime/unittests/Runtime/Stop.cpp
+++ b/FortranRuntime/unittests/Runtime/Stop.cpp
@@ -10,8 +10,8 @@
 //
 //===----------------------------------------------------------------------===//
 #include "flang/Runtime/stop.h"
-#include "CrashHandlerFixture.h"
 #include "../../lib/Runtime/environment.h"
+#include "CrashHandlerFixture.h"
 #include <cstdlib>
 #include <gtest/gtest.h>
 
diff --git a/FortranRuntime/unittests/Runtime/Support.cpp b/FortranRuntime/unittests/Runtime/Support.cpp
index b7aa39ef5523ba..38c0d6efaf9db7 100644
--- a/FortranRuntime/unittests/Runtime/Support.cpp
+++ b/FortranRuntime/unittests/Runtime/Support.cpp
@@ -7,9 +7,9 @@
 //===----------------------------------------------------------------------===//
 
 #include "flang/Runtime/support.h"
-#include "gtest/gtest.h"
-#include "tools.h"
 #include "flang/Runtime/descriptor.h"
+#include "tools.h"
+#include "gtest/gtest.h"
 
 using namespace Fortran::runtime;
 using Fortran::common::TypeCategory;
diff --git a/FortranRuntime/unittests/Runtime/TemporaryStack.cpp b/FortranRuntime/unittests/Runtime/TemporaryStack.cpp
index 495c693b0493ef..63d99416ea64cb 100644
--- a/FortranRuntime/unittests/Runtime/TemporaryStack.cpp
+++ b/FortranRuntime/unittests/Runtime/TemporaryStack.cpp
@@ -6,14 +6,14 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "gtest/gtest.h"
-#include "tools.h"
 #include "flang/Common/ISO_Fortran_binding_wrapper.h"
 #include "flang/Runtime/allocatable.h"
 #include "flang/Runtime/cpp-type.h"
 #include "flang/Runtime/descriptor.h"
 #include "flang/Runtime/temporary-stack.h"
 #include "flang/Runtime/type-code.h"
+#include "tools.h"
+#include "gtest/gtest.h"
 #include <vector>
 
 using namespace Fortran::runtime;
diff --git a/FortranRuntime/unittests/Runtime/Time.cpp b/FortranRuntime/unittests/Runtime/Time.cpp
index 548c0834e34a36..6fd00d669a9575 100644
--- a/FortranRuntime/unittests/Runtime/Time.cpp
+++ b/FortranRuntime/unittests/Runtime/Time.cpp
@@ -6,8 +6,8 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "gtest/gtest.h"
 #include "flang/Runtime/time-intrinsic.h"
+#include "gtest/gtest.h"
 #include <algorithm>
 #include <cctype>
 #include <cerrno>
diff --git a/FortranRuntime/unittests/Runtime/Transformational.cpp b/FortranRuntime/unittests/Runtime/Transformational.cpp
index 2dcab5a2aa8974..b5a4e0e8e9588b 100644
--- a/FortranRuntime/unittests/Runtime/Transformational.cpp
+++ b/FortranRuntime/unittests/Runtime/Transformational.cpp
@@ -7,10 +7,10 @@
 //===----------------------------------------------------------------------===//
 
 #include "flang/Runtime/transformational.h"
-#include "gtest/gtest.h"
-#include "tools.h"
 #include "flang/Common/float128.h"
 #include "flang/Runtime/type-code.h"
+#include "tools.h"
+#include "gtest/gtest.h"
 #include <vector>
 
 using namespace Fortran::runtime;
diff --git a/FortranRuntime/unittests/Runtime/tools.h b/FortranRuntime/unittests/Runtime/tools.h
index a8e2096a90572e..702103d225ab72 100644
--- a/FortranRuntime/unittests/Runtime/tools.h
+++ b/FortranRuntime/unittests/Runtime/tools.h
@@ -9,11 +9,11 @@
 #ifndef FORTRAN_UNITTESTS_RUNTIME_TOOLS_H_
 #define FORTRAN_UNITTESTS_RUNTIME_TOOLS_H_
 
-#include "gtest/gtest.h"
 #include "flang/Runtime/allocatable.h"
 #include "flang/Runtime/cpp-type.h"
 #include "flang/Runtime/descriptor.h"
 #include "flang/Runtime/type-code.h"
+#include "gtest/gtest.h"
 #include <cstdint>
 #include <cstring>
 #include <vector>
@@ -54,4 +54,4 @@ static OwningPtr<Descriptor> MakeArray(const std::vector<int> &shape,
 }
 
 } // namespace Fortran::runtime
-#endif // FORTRAN_UNITTESTS_RUNTIME_TOOLS_H_
+#endif /* FORTRAN_UNITTESTS_RUNTIME_TOOLS_H_ */
diff --git a/flang/CMakeLists.txt b/flang/CMakeLists.txt
index 00e570798bb412..47517c5e7ab82f 100644
--- a/flang/CMakeLists.txt
+++ b/flang/CMakeLists.txt
@@ -160,6 +160,7 @@ if (FLANG_STANDALONE_BUILD)
 
   link_directories("${LLVM_LIBRARY_DIR}")
 
+  set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
   set(CMAKE_LIBRARY_OUTPUT_DIRECTORY
     ${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX})
   set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY
@@ -238,6 +239,7 @@ include_directories(SYSTEM ${CLANG_INCLUDE_DIR})
 
 # tco tool and FIR lib output directories
 if(FLANG_STANDALONE_BUILD)
+  set(LLVM_RUNTIME_OUTPUT_INTDIR ${CMAKE_BINARY_DIR}/bin)
   set(LLVM_LIBRARY_OUTPUT_INTDIR ${CMAKE_BINARY_DIR}/lib)
 endif()
 # Always build tco tool
diff --git a/flang/include/flang/Evaluate/call.h b/flang/include/flang/Evaluate/call.h
index 8137185da61442..080f78c4e80fc0 100644
--- a/flang/include/flang/Evaluate/call.h
+++ b/flang/include/flang/Evaluate/call.h
@@ -13,11 +13,11 @@
 #include "constant.h"
 #include "formatting.h"
 #include "type.h"
+#include "flang/Parser/char-block.h"
+#include "flang/Semantics/attr.h"
 #include "flang/Support/Fortran.h"
 #include "flang/Support/indirection.h"
 #include "flang/Support/reference.h"
-#include "flang/Parser/char-block.h"
-#include "flang/Semantics/attr.h"
 #include <optional>
 #include <vector>
 
diff --git a/flang/include/flang/Evaluate/characteristics.h b/flang/include/flang/Evaluate/characteristics.h
index 8f1e6876d88d58..e40155fb287b62 100644
--- a/flang/include/flang/Evaluate/characteristics.h
+++ b/flang/include/flang/Evaluate/characteristics.h
@@ -18,13 +18,13 @@
 #include "shape.h"
 #include "tools.h"
 #include "type.h"
-#include "flang/Support/Fortran-features.h"
-#include "flang/Support/Fortran.h"
 #include "flang/Common/enum-set.h"
 #include "flang/Common/idioms.h"
-#include "flang/Support/indirection.h"
 #include "flang/Parser/char-block.h"
 #include "flang/Semantics/symbol.h"
+#include "flang/Support/Fortran-features.h"
+#include "flang/Support/Fortran.h"
+#include "flang/Support/indirection.h"
 #include <optional>
 #include <string>
 #include <variant>
diff --git a/flang/include/flang/Evaluate/common.h b/flang/include/flang/Evaluate/common.h
index 69f09a930dc604..91d38748f5a575 100644
--- a/flang/include/flang/Evaluate/common.h
+++ b/flang/include/flang/Evaluate/common.h
@@ -9,17 +9,16 @@
 #ifndef FORTRAN_EVALUATE_COMMON_H_
 #define FORTRAN_EVALUATE_COMMON_H_
 
-#include "flang/Support/Fortran-features.h"
-#include "flang/Support/Fortran.h"
-#include "flang/Support/default-kinds.h"
 #include "flang/Common/enum-set.h"
 #include "flang/Common/idioms.h"
-#include "flang/Support/indirection.h"
-#include "flang/Common/Fortran-consts.h"
 #include "flang/Common/restorer.h"
+#include "flang/Common/target-rounding.h"
 #include "flang/Parser/char-block.h"
 #include "flang/Parser/message.h"
-#include "flang/Common/target-rounding.h"
+#include "flang/Support/Fortran-features.h"
+#include "flang/Support/Fortran.h"
+#include "flang/Support/default-kinds.h"
+#include "flang/Support/indirection.h"
 #include <cinttypes>
 #include <map>
 #include <set>
@@ -34,10 +33,9 @@ class IntrinsicProcTable;
 class TargetCharacteristics;
 
 using common::ConstantSubscript;
-using common::RelationalOperator;
-using common::RoundingMode;
-using common::RealFlags;
 using common::RealFlag;
+using common::RealFlags;
+using common::RelationalOperator;
 
 // Integers are always ordered; reals may not be.
 ENUM_CLASS(Ordering, Less, Equal, Greater)
diff --git a/flang/include/flang/Evaluate/expression.h b/flang/include/flang/Evaluate/expression.h
index a582a2ea1a6989..20e8725f91d5e5 100644
--- a/flang/include/flang/Evaluate/expression.h
+++ b/flang/include/flang/Evaluate/expression.h
@@ -21,11 +21,11 @@
 #include "formatting.h"
 #include "type.h"
 #include "variable.h"
-#include "flang/Support/Fortran.h"
 #include "flang/Common/idioms.h"
+#include "flang/Parser/char-block.h"
+#include "flang/Support/Fortran.h"
 #include "flang/Support/indirection.h"
 #include "flang/Support/template.h"
-#include "flang/Parser/char-block.h"
 #include <algorithm>
 #include <list>
 #include <tuple>
diff --git a/flang/include/flang/Evaluate/intrinsics.h b/flang/include/flang/Evaluate/intrinsics.h
index 17f555445f6f79..dbe1ba7fe7ec1b 100644
--- a/flang/include/flang/Evaluate/intrinsics.h
+++ b/flang/include/flang/Evaluate/intrinsics.h
@@ -12,9 +12,9 @@
 #include "call.h"
 #include "characteristics.h"
 #include "type.h"
-#include "flang/Support/default-kinds.h"
 #include "flang/Parser/char-block.h"
 #include "flang/Parser/message.h"
+#include "flang/Support/default-kinds.h"
 #include <memory>
 #include <optional>
 #include <string>
diff --git a/flang/include/flang/Evaluate/shape.h b/flang/include/flang/Evaluate/shape.h
index f3eeea7984bba7..8e8d89ffd8d108 100644
--- a/flang/include/flang/Evaluate/shape.h
+++ b/flang/include/flang/Evaluate/shape.h
@@ -15,8 +15,8 @@
 #include "expression.h"
 #include "traverse.h"
 #include "variable.h"
-#include "flang/Support/indirection.h"
 #include "flang/Evaluate/type.h"
+#include "flang/Support/indirection.h"
 #include <optional>
 #include <variant>
 
diff --git a/flang/include/flang/Evaluate/target.h b/flang/include/flang/Evaluate/target.h
index 8f52b29bec6654..11ac41a5deb69f 100644
--- a/flang/include/flang/Evaluate/target.h
+++ b/flang/include/flang/Evaluate/target.h
@@ -12,11 +12,11 @@
 #ifndef FORTRAN_EVALUATE_TARGET_H_
 #define FORTRAN_EVALUATE_TARGET_H_
 
-#include "flang/Support/Fortran.h"
 #include "flang/Common/enum-class.h"
 #include "flang/Common/enum-set.h"
 #include "flang/Common/target-rounding.h"
 #include "flang/Evaluate/common.h"
+#include "flang/Support/Fortran.h"
 #include <cstdint>
 
 namespace Fortran::evaluate {
diff --git a/flang/include/flang/Evaluate/tools.h b/flang/include/flang/Evaluate/tools.h
index 29d19bff44c79c..9e1c25a3529380 100644
--- a/flang/include/flang/Evaluate/tools.h
+++ b/flang/include/flang/Evaluate/tools.h
@@ -11,8 +11,6 @@
 
 #include "traverse.h"
 #include "flang/Common/idioms.h"
-#include "flang/Support/template.h"
-#include "flang/Support/unwrap.h"
 #include "flang/Evaluate/constant.h"
 #include "flang/Evaluate/expression.h"
 #include "flang/Evaluate/shape.h"
@@ -21,6 +19,8 @@
 #include "flang/Semantics/attr.h"
 #include "flang/Semantics/scope.h"
 #include "flang/Semantics/symbol.h"
+#include "flang/Support/template.h"
+#include "flang/Support/unwrap.h"
 #include <array>
 #include <optional>
 #include <set>
diff --git a/flang/include/flang/Evaluate/traverse.h b/flang/include/flang/Evaluate/traverse.h
index e04888f395c013..508d4ca76b30f6 100644
--- a/flang/include/flang/Evaluate/traverse.h
+++ b/flang/include/flang/Evaluate/traverse.h
@@ -38,9 +38,9 @@
 // expression of an ASSOCIATE (or related) construct entity.
 
 #include "expression.h"
-#include "flang/Support/indirection.h"
 #include "flang/Semantics/symbol.h"
 #include "flang/Semantics/type.h"
+#include "flang/Support/indirection.h"
 #include <set>
 #include <type_traits>
 
diff --git a/flang/include/flang/Evaluate/type.h b/flang/include/flang/Evaluate/type.h
index b68a5790c810fd..93311e3d2e5ae0 100644
--- a/flang/include/flang/Evaluate/type.h
+++ b/flang/include/flang/Evaluate/type.h
@@ -22,10 +22,10 @@
 #include "integer.h"
 #include "logical.h"
 #include "real.h"
-#include "flang/Support/Fortran-features.h"
-#include "flang/Support/Fortran.h"
 #include "flang/Common/idioms.h"
 #include "flang/Common/real.h"
+#include "flang/Support/Fortran-features.h"
+#include "flang/Support/Fortran.h"
 #include "flang/Support/template.h"
 #include <cinttypes>
 #include <optional>
diff --git a/flang/include/flang/Evaluate/variable.h b/flang/include/flang/Evaluate/variable.h
index 8d0da5b24277cd..161625b6887189 100644
--- a/flang/include/flang/Evaluate/variable.h
+++ b/flang/include/flang/Evaluate/variable.h
@@ -21,9 +21,9 @@
 #include "static-data.h"
 #include "type.h"
 #include "flang/Common/idioms.h"
+#include "flang/Parser/char-block.h"
 #include "flang/Support/reference.h"
 #include "flang/Support/template.h"
-#include "flang/Parser/char-block.h"
 #include <optional>
 #include <variant>
 #include <vector>
diff --git a/flang/include/flang/Frontend/FrontendOptions.h b/flang/include/flang/Frontend/FrontendOptions.h
index b69ffe83de1707..c436eb4cbac6f3 100644
--- a/flang/include/flang/Frontend/FrontendOptions.h
+++ b/flang/include/flang/Frontend/FrontendOptions.h
@@ -13,10 +13,10 @@
 #ifndef FORTRAN_FRONTEND_FRONTENDOPTIONS_H
 #define FORTRAN_FRONTEND_FRONTENDOPTIONS_H
 
-#include "flang/Support/Fortran-features.h"
 #include "flang/Lower/EnvironmentDefault.h"
 #include "flang/Parser/characters.h"
 #include "flang/Parser/unparse.h"
+#include "flang/Support/Fortran-features.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include <cstdint>
diff --git a/flang/include/flang/Lower/AbstractConverter.h b/flang/include/flang/Lower/AbstractConverter.h
index 56646c196a7de5..6c8d77db2202b5 100644
--- a/flang/include/flang/Lower/AbstractConverter.h
+++ b/flang/include/flang/Lower/AbstractConverter.h
@@ -13,12 +13,12 @@
 #ifndef FORTRAN_LOWER_ABSTRACTCONVERTER_H
 #define FORTRAN_LOWER_ABSTRACTCONVERTER_H
 
-#include "flang/Support/Fortran.h"
 #include "flang/Lower/LoweringOptions.h"
 #include "flang/Lower/PFTDefs.h"
 #include "flang/Optimizer/Builder/BoxValue.h"
 #include "flang/Optimizer/Dialect/FIRAttr.h"
 #include "flang/Semantics/symbol.h"
+#include "flang/Support/Fortran.h"
 #include "mlir/IR/Builders.h"
 #include "mlir/IR/BuiltinOps.h"
 #include "mlir/IR/Operation.h"
diff --git a/flang/include/flang/Lower/Bridge.h b/flang/include/flang/Lower/Bridge.h
index 0c2c7abc324952..f07207c5026ebd 100644
--- a/flang/include/flang/Lower/Bridge.h
+++ b/flang/include/flang/Lower/Bridge.h
@@ -13,13 +13,13 @@
 #ifndef FORTRAN_LOWER_BRIDGE_H
 #define FORTRAN_LOWER_BRIDGE_H
 
-#include "flang/Support/Fortran.h"
 #include "flang/Lower/AbstractConverter.h"
 #include "flang/Lower/EnvironmentDefault.h"
 #include "flang/Lower/LoweringOptions.h"
 #include "flang/Lower/StatementContext.h"
 #include "flang/Optimizer/Builder/FIRBuilder.h"
 #include "flang/Optimizer/Dialect/Support/KindMapping.h"
+#include "flang/Support/Fortran.h"
 #include "mlir/IR/BuiltinOps.h"
 #include <set>
 
diff --git a/flang/include/flang/Lower/CallInterface.h b/flang/include/flang/Lower/CallInterface.h
index df01eafe679d7d..b16ad7a91afd0a 100644
--- a/flang/include/flang/Lower/CallInterface.h
+++ b/flang/include/flang/Lower/CallInterface.h
@@ -27,8 +27,8 @@
 #ifndef FORTRAN_LOWER_CALLINTERFACE_H
 #define FORTRAN_LOWER_CALLINTERFACE_H
 
-#include "flang/Support/reference.h"
 #include "flang/Evaluate/characteristics.h"
+#include "flang/Support/reference.h"
 #include "mlir/Dialect/Func/IR/FuncOps.h"
 #include "mlir/IR/BuiltinOps.h"
 #include <memory>
diff --git a/flang/include/flang/Lower/ConvertType.h b/flang/include/flang/Lower/ConvertType.h
index b889d2bb279de2..179a6825840464 100644
--- a/flang/include/flang/Lower/ConvertType.h
+++ b/flang/include/flang/Lower/ConvertType.h
@@ -21,8 +21,8 @@
 #ifndef FORTRAN_LOWER_CONVERT_TYPE_H
 #define FORTRAN_LOWER_CONVERT_TYPE_H
 
-#include "flang/Support/Fortran.h"
 #include "flang/Evaluate/type.h"
+#include "flang/Support/Fortran.h"
 #include "mlir/IR/BuiltinTypes.h"
 
 namespace mlir {
diff --git a/flang/include/flang/Lower/PFTBuilder.h b/flang/include/flang/Lower/PFTBuilder.h
index 7ee61e630581fe..b2e0d776a228b1 100644
--- a/flang/include/flang/Lower/PFTBuilder.h
+++ b/flang/include/flang/Lower/PFTBuilder.h
@@ -17,8 +17,6 @@
 #ifndef FORTRAN_LOWER_PFTBUILDER_H
 #define FORTRAN_LOWER_PFTBUILDER_H
 
-#include "flang/Support/reference.h"
-#include "flang/Support/template.h"
 #include "flang/Lower/HostAssociations.h"
 #include "flang/Lower/PFTDefs.h"
 #include "flang/Parser/parse-tree.h"
@@ -26,6 +24,8 @@
 #include "flang/Semantics/scope.h"
 #include "flang/Semantics/semantics.h"
 #include "flang/Semantics/symbol.h"
+#include "flang/Support/reference.h"
+#include "flang/Support/template.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/raw_ostream.h"
 
diff --git a/flang/include/flang/Lower/Support/Utils.h b/flang/include/flang/Lower/Support/Utils.h
index a09cfb16f7805a..08a872b228691d 100644
--- a/flang/include/flang/Lower/Support/Utils.h
+++ b/flang/include/flang/Lower/Support/Utils.h
@@ -13,9 +13,9 @@
 #ifndef FORTRAN_LOWER_SUPPORT_UTILS_H
 #define FORTRAN_LOWER_SUPPORT_UTILS_H
 
-#include "flang/Support/indirection.h"
 #include "flang/Parser/char-block.h"
 #include "flang/Semantics/tools.h"
+#include "flang/Support/indirection.h"
 #include "mlir/Dialect/Arith/IR/Arith.h"
 #include "mlir/Dialect/Func/IR/FuncOps.h"
 #include "mlir/IR/BuiltinAttributes.h"
diff --git a/flang/include/flang/Lower/SymbolMap.h b/flang/include/flang/Lower/SymbolMap.h
index 7bba02e41a3bdf..fb64db407708ad 100644
--- a/flang/include/flang/Lower/SymbolMap.h
+++ b/flang/include/flang/Lower/SymbolMap.h
@@ -13,12 +13,12 @@
 #ifndef FORTRAN_LOWER_SYMBOLMAP_H
 #define FORTRAN_LOWER_SYMBOLMAP_H
 
-#include "flang/Support/reference.h"
 #include "flang/Optimizer/Builder/BoxValue.h"
 #include "flang/Optimizer/Dialect/FIRType.h"
 #include "flang/Optimizer/Dialect/FortranVariableInterface.h"
 #include "flang/Optimizer/Support/Matcher.h"
 #include "flang/Semantics/symbol.h"
+#include "flang/Support/reference.h"
 #include "mlir/IR/Value.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/DenseMap.h"
diff --git a/flang/include/flang/Optimizer/Builder/FIRBuilder.h b/flang/include/flang/Optimizer/Builder/FIRBuilder.h
index 90279417b5c939..14c1d5033fab40 100644
--- a/flang/include/flang/Optimizer/Builder/FIRBuilder.h
+++ b/flang/include/flang/Optimizer/Builder/FIRBuilder.h
@@ -16,12 +16,12 @@
 #ifndef FORTRAN_OPTIMIZER_BUILDER_FIRBUILDER_H
 #define FORTRAN_OPTIMIZER_BUILDER_FIRBUILDER_H
 
-#include "flang/Support/MathOptionsBase.h"
 #include "flang/Optimizer/Dialect/FIROps.h"
 #include "flang/Optimizer/Dialect/FIROpsSupport.h"
 #include "flang/Optimizer/Dialect/FIRType.h"
 #include "flang/Optimizer/Dialect/Support/FIRContext.h"
 #include "flang/Optimizer/Dialect/Support/KindMapping.h"
+#include "flang/Support/MathOptionsBase.h"
 #include "mlir/IR/Builders.h"
 #include "mlir/IR/BuiltinOps.h"
 #include "llvm/ADT/DenseMap.h"
diff --git a/flang/include/flang/Optimizer/Builder/PPCIntrinsicCall.h b/flang/include/flang/Optimizer/Builder/PPCIntrinsicCall.h
index 26cf34188eb568..2a3e85988184b4 100644
--- a/flang/include/flang/Optimizer/Builder/PPCIntrinsicCall.h
+++ b/flang/include/flang/Optimizer/Builder/PPCIntrinsicCall.h
@@ -9,8 +9,8 @@
 #ifndef FORTRAN_LOWER_PPCINTRINSICCALL_H
 #define FORTRAN_LOWER_PPCINTRINSICCALL_H
 
-#include "flang/Support/static-multimap-view.h"
 #include "flang/Optimizer/Builder/IntrinsicCall.h"
+#include "flang/Support/static-multimap-view.h"
 #include "mlir/Dialect/Math/IR/Math.h"
 
 namespace fir {
diff --git a/flang/include/flang/Optimizer/Builder/Runtime/RTBuilder.h b/flang/include/flang/Optimizer/Builder/Runtime/RTBuilder.h
index 104e363e689857..e9fb177d311c01 100644
--- a/flang/include/flang/Optimizer/Builder/Runtime/RTBuilder.h
+++ b/flang/include/flang/Optimizer/Builder/Runtime/RTBuilder.h
@@ -17,12 +17,12 @@
 #ifndef FORTRAN_OPTIMIZER_BUILDER_RUNTIME_RTBUILDER_H
 #define FORTRAN_OPTIMIZER_BUILDER_RUNTIME_RTBUILDER_H
 
-#include "flang/Support/Fortran.h"
 #include "flang/Common/uint128.h"
 #include "flang/Optimizer/Builder/FIRBuilder.h"
 #include "flang/Optimizer/Dialect/FIRDialect.h"
 #include "flang/Optimizer/Dialect/FIRType.h"
 #include "flang/Runtime/reduce.h"
+#include "flang/Support/Fortran.h"
 #include "mlir/IR/BuiltinTypes.h"
 #include "mlir/IR/MLIRContext.h"
 #include "llvm/ADT/SmallVector.h"
diff --git a/flang/include/flang/Optimizer/Support/Utils.h b/flang/include/flang/Optimizer/Support/Utils.h
index 631322b34c49e5..88d38cb7574813 100644
--- a/flang/include/flang/Optimizer/Support/Utils.h
+++ b/flang/include/flang/Optimizer/Support/Utils.h
@@ -13,13 +13,13 @@
 #ifndef FORTRAN_OPTIMIZER_SUPPORT_UTILS_H
 #define FORTRAN_OPTIMIZER_SUPPORT_UTILS_H
 
-#include "flang/Support/default-kinds.h"
 #include "flang/Optimizer/Builder/FIRBuilder.h"
 #include "flang/Optimizer/Builder/Todo.h"
 #include "flang/Optimizer/Dialect/CUF/Attributes/CUFAttr.h"
 #include "flang/Optimizer/Dialect/FIROps.h"
 #include "flang/Optimizer/Dialect/FIRType.h"
 #include "flang/Optimizer/Support/FatalError.h"
+#include "flang/Support/default-kinds.h"
 #include "mlir/Dialect/Arith/IR/Arith.h"
 #include "mlir/Dialect/Func/IR/FuncOps.h"
 #include "mlir/IR/BuiltinAttributes.h"
diff --git a/flang/include/flang/Parser/dump-parse-tree.h b/flang/include/flang/Parser/dump-parse-tree.h
index f98ac17b6ecba7..30ea08806430a9 100644
--- a/flang/include/flang/Parser/dump-parse-tree.h
+++ b/flang/include/flang/Parser/dump-parse-tree.h
@@ -14,8 +14,8 @@
 #include "parse-tree.h"
 #include "tools.h"
 #include "unparse.h"
-#include "flang/Support/Fortran.h"
 #include "flang/Common/idioms.h"
+#include "flang/Support/Fortran.h"
 #include "flang/Support/indirection.h"
 #include "llvm/Support/raw_ostream.h"
 #include <string>
diff --git a/flang/include/flang/Parser/message.h b/flang/include/flang/Parser/message.h
index 70746bf551f2d7..c3d4a78c2c0023 100644
--- a/flang/include/flang/Parser/message.h
+++ b/flang/include/flang/Parser/message.h
@@ -16,8 +16,8 @@
 #include "char-set.h"
 #include "provenance.h"
 #include "flang/Common/idioms.h"
-#include "flang/Support/reference-counted.h"
 #include "flang/Common/restorer.h"
+#include "flang/Support/reference-counted.h"
 #include <cstddef>
 #include <cstring>
 #include <forward_list>
diff --git a/flang/include/flang/Parser/parse-state.h b/flang/include/flang/Parser/parse-state.h
index 20d339aeeccccf..36d70b81b79236 100644
--- a/flang/include/flang/Parser/parse-state.h
+++ b/flang/include/flang/Parser/parse-state.h
@@ -16,11 +16,11 @@
 // and recovery during parsing!
 
 #include "user-state.h"
-#include "flang/Support/Fortran-features.h"
 #include "flang/Common/idioms.h"
 #include "flang/Parser/characters.h"
 #include "flang/Parser/message.h"
 #include "flang/Parser/provenance.h"
+#include "flang/Support/Fortran-features.h"
 #include <cstddef>
 #include <cstring>
 #include <list>
diff --git a/flang/include/flang/Parser/parse-tree.h b/flang/include/flang/Parser/parse-tree.h
index a6d19dd6435966..de869f8200a261 100644
--- a/flang/include/flang/Parser/parse-tree.h
+++ b/flang/include/flang/Parser/parse-tree.h
@@ -22,8 +22,8 @@
 #include "format-specification.h"
 #include "message.h"
 #include "provenance.h"
-#include "flang/Support/Fortran.h"
 #include "flang/Common/idioms.h"
+#include "flang/Support/Fortran.h"
 #include "flang/Support/indirection.h"
 #include "llvm/Frontend/OpenACC/ACC.h.inc"
 #include "llvm/Frontend/OpenMP/OMPConstants.h"
diff --git a/flang/include/flang/Parser/parsing.h b/flang/include/flang/Parser/parsing.h
index b0de98737f536e..0e608cb220d2c5 100644
--- a/flang/include/flang/Parser/parsing.h
+++ b/flang/include/flang/Parser/parsing.h
@@ -14,8 +14,8 @@
 #include "message.h"
 #include "parse-tree.h"
 #include "provenance.h"
-#include "flang/Support/Fortran-features.h"
 #include "flang/Parser/preprocessor.h"
+#include "flang/Support/Fortran-features.h"
 #include "llvm/Support/raw_ostream.h"
 #include <optional>
 #include <string>
diff --git a/flang/include/flang/Parser/user-state.h b/flang/include/flang/Parser/user-state.h
index fff651208e0e52..129f9fb8fee058 100644
--- a/flang/include/flang/Parser/user-state.h
+++ b/flang/include/flang/Parser/user-state.h
@@ -14,10 +14,10 @@
 // parse tree construction so as to avoid any need for representing
 // state in static data.
 
-#include "flang/Support/Fortran-features.h"
 #include "flang/Common/idioms.h"
 #include "flang/Parser/char-block.h"
 #include "flang/Parser/parse-tree.h"
+#include "flang/Support/Fortran-features.h"
 #include "llvm/Support/raw_ostream.h"
 #include <cinttypes>
 #include <optional>
diff --git a/flang/include/flang/Semantics/expression.h b/flang/include/flang/Semantics/expression.h
index 77e26ffb834dd9..194cb746ff8a84 100644
--- a/flang/include/flang/Semantics/expression.h
+++ b/flang/include/flang/Semantics/expression.h
@@ -10,8 +10,6 @@
 #define FORTRAN_SEMANTICS_EXPRESSION_H_
 
 #include "semantics.h"
-#include "flang/Support/Fortran.h"
-#include "flang/Support/indirection.h"
 #include "flang/Common/restorer.h"
 #include "flang/Common/visit.h"
 #include "flang/Evaluate/characteristics.h"
@@ -24,6 +22,8 @@
 #include "flang/Parser/parse-tree-visitor.h"
 #include "flang/Parser/parse-tree.h"
 #include "flang/Parser/tools.h"
+#include "flang/Support/Fortran.h"
+#include "flang/Support/indirection.h"
 #include <map>
 #include <optional>
 #include <type_traits>
diff --git a/flang/include/flang/Semantics/runtime-type-info.h b/flang/include/flang/Semantics/runtime-type-info.h
index 3f9f776797d782..94c50aab696816 100644
--- a/flang/include/flang/Semantics/runtime-type-info.h
+++ b/flang/include/flang/Semantics/runtime-type-info.h
@@ -14,8 +14,8 @@
 #ifndef FORTRAN_SEMANTICS_RUNTIME_TYPE_INFO_H_
 #define FORTRAN_SEMANTICS_RUNTIME_TYPE_INFO_H_
 
-#include "flang/Support/reference.h"
 #include "flang/Semantics/symbol.h"
+#include "flang/Support/reference.h"
 #include <map>
 #include <set>
 #include <string>
diff --git a/flang/include/flang/Semantics/scope.h b/flang/include/flang/Semantics/scope.h
index 8b416dcffb5245..72e8bab71b6c70 100644
--- a/flang/include/flang/Semantics/scope.h
+++ b/flang/include/flang/Semantics/scope.h
@@ -11,11 +11,11 @@
 
 #include "attr.h"
 #include "symbol.h"
-#include "flang/Support/Fortran.h"
 #include "flang/Common/idioms.h"
-#include "flang/Support/reference.h"
 #include "flang/Parser/message.h"
 #include "flang/Parser/provenance.h"
+#include "flang/Support/Fortran.h"
+#include "flang/Support/reference.h"
 #include <list>
 #include <map>
 #include <optional>
diff --git a/flang/include/flang/Semantics/semantics.h b/flang/include/flang/Semantics/semantics.h
index 899d4afa016bff..abce30f725d972 100644
--- a/flang/include/flang/Semantics/semantics.h
+++ b/flang/include/flang/Semantics/semantics.h
@@ -11,12 +11,12 @@
 
 #include "scope.h"
 #include "symbol.h"
-#include "flang/Support/Fortran-features.h"
 #include "flang/Evaluate/common.h"
 #include "flang/Evaluate/intrinsics.h"
 #include "flang/Evaluate/target.h"
 #include "flang/Parser/message.h"
 #include "flang/Semantics/module-dependences.h"
+#include "flang/Support/Fortran-features.h"
 #include <iosfwd>
 #include <set>
 #include <string>
diff --git a/flang/include/flang/Semantics/symbol.h b/flang/include/flang/Semantics/symbol.h
index 29587be2c7d77d..d207cfe7d7421a 100644
--- a/flang/include/flang/Semantics/symbol.h
+++ b/flang/include/flang/Semantics/symbol.h
@@ -10,11 +10,11 @@
 #define FORTRAN_SEMANTICS_SYMBOL_H_
 
 #include "type.h"
-#include "flang/Support/Fortran.h"
 #include "flang/Common/enum-set.h"
-#include "flang/Support/reference.h"
 #include "flang/Common/visit.h"
 #include "flang/Semantics/module-dependences.h"
+#include "flang/Support/Fortran.h"
+#include "flang/Support/reference.h"
 #include "llvm/ADT/DenseMapInfo.h"
 
 #include <array>
diff --git a/flang/include/flang/Semantics/tools.h b/flang/include/flang/Semantics/tools.h
index 9be7ebff9b5bb6..e31de6e958a8c4 100644
--- a/flang/include/flang/Semantics/tools.h
+++ b/flang/include/flang/Semantics/tools.h
@@ -12,7 +12,6 @@
 // Simple predicates and look-up functions that are best defined
 // canonically for use in semantic checking.
 
-#include "flang/Support/Fortran.h"
 #include "flang/Common/visit.h"
 #include "flang/Evaluate/expression.h"
 #include "flang/Evaluate/shape.h"
@@ -23,6 +22,7 @@
 #include "flang/Semantics/attr.h"
 #include "flang/Semantics/expression.h"
 #include "flang/Semantics/semantics.h"
+#include "flang/Support/Fortran.h"
 #include <functional>
 
 namespace Fortran::semantics {
diff --git a/flang/include/flang/Semantics/type.h b/flang/include/flang/Semantics/type.h
index fd31bc805e2de6..210ea7a129376d 100644
--- a/flang/include/flang/Semantics/type.h
+++ b/flang/include/flang/Semantics/type.h
@@ -9,10 +9,10 @@
 #ifndef FORTRAN_SEMANTICS_TYPE_H_
 #define FORTRAN_SEMANTICS_TYPE_H_
 
-#include "flang/Support/Fortran.h"
 #include "flang/Common/idioms.h"
 #include "flang/Evaluate/expression.h"
 #include "flang/Parser/char-block.h"
+#include "flang/Support/Fortran.h"
 #include <algorithm>
 #include <iosfwd>
 #include <map>
diff --git a/flang/include/flang/Support/Fortran-features.h b/flang/include/flang/Support/Fortran-features.h
index f0bfc9232ea9e9..718ce680afeeab 100644
--- a/flang/include/flang/Support/Fortran-features.h
+++ b/flang/include/flang/Support/Fortran-features.h
@@ -9,9 +9,9 @@
 #ifndef FORTRAN_COMMON_FORTRAN_FEATURES_H_
 #define FORTRAN_COMMON_FORTRAN_FEATURES_H_
 
-#include "flang/Support/Fortran.h"
 #include "flang/Common/enum-set.h"
 #include "flang/Common/idioms.h"
+#include "flang/Support/Fortran.h"
 #include <vector>
 
 namespace Fortran::common {
diff --git a/flang/include/flang/Support/Fortran.h b/flang/include/flang/Support/Fortran.h
index 6dbfb51f19dd8e..343a0b30d2ba9c 100644
--- a/flang/include/flang/Support/Fortran.h
+++ b/flang/include/flang/Support/Fortran.h
@@ -1,4 +1,4 @@
-//===-- include/flang/Support/Fortran.h -------------------------*- C++ -*-===//
+//===-- include/flang/Common/Fortran.h --------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -9,7 +9,8 @@
 #ifndef FORTRAN_COMMON_FORTRAN_H_
 #define FORTRAN_COMMON_FORTRAN_H_
 
-
+// Fortran language concepts that are used in many phases are defined
+// once here to avoid redundancy and needless translation.
 
 #include "flang/Common/Fortran-consts.h"
 #include "flang/Common/enum-set.h"
@@ -18,11 +19,8 @@
 #include <optional>
 #include <string>
 
-
 namespace Fortran::common {
-	class LanguageFeatureControl;
-
-
+class LanguageFeatureControl;
 
 constexpr bool IsNumericTypeCategory(TypeCategory category) {
   return category == TypeCategory::Integer || category == TypeCategory::Real ||
@@ -46,7 +44,6 @@ const char *AsFortran(RelationalOperator);
 
 ENUM_CLASS(Intent, Default, In, Out, InOut)
 
-
 // Union of specifiers for all I/O statements.
 ENUM_CLASS(IoSpecKind, Access, Action, Advance, Asynchronous, Blank, Decimal,
     Delim, Direct, Encoding, End, Eor, Err, Exist, File, Fmt, Form, Formatted,
@@ -58,15 +55,11 @@ ENUM_CLASS(IoSpecKind, Access, Action, Advance, Asynchronous, Blank, Decimal,
     Dispose, // nonstandard
 )
 
-
 const char *AsFortran(DefinedIo);
 
-
 // Fortran label. Must be in [1..99999].
 using Label = std::uint64_t;
 
-
-
 // CUDA subprogram attribute combinations
 ENUM_CLASS(CUDASubprogramAttrs, Host, Device, HostDevice, Global, Grid_Global)
 
@@ -112,5 +105,6 @@ inline std::string GetExternalAssemblyName(
     std::string symbolName, bool underscoring) {
   return underscoring ? std::move(symbolName) + "_" : std::move(symbolName);
 }
+
 } // namespace Fortran::common
 #endif // FORTRAN_COMMON_FORTRAN_H_
diff --git a/flang/include/flang/Support/template.h b/flang/include/flang/Support/template.h
index e15de9c2d0cea8..58c9b0a5628e8a 100644
--- a/flang/include/flang/Support/template.h
+++ b/flang/include/flang/Support/template.h
@@ -9,8 +9,8 @@
 #ifndef FORTRAN_COMMON_TEMPLATE_H_
 #define FORTRAN_COMMON_TEMPLATE_H_
 
-#include "flang/Common/variant.h"
 #include "flang/Common/idioms.h"
+#include "flang/Common/variant.h"
 #include <functional>
 #include <optional>
 #include <tuple>
diff --git a/flang/include/flang/Tools/CrossToolHelpers.h b/flang/include/flang/Tools/CrossToolHelpers.h
index bc105f471aa003..168c3aefe0cd41 100644
--- a/flang/include/flang/Tools/CrossToolHelpers.h
+++ b/flang/include/flang/Tools/CrossToolHelpers.h
@@ -13,9 +13,9 @@
 #ifndef FORTRAN_TOOLS_CROSS_TOOL_HELPERS_H
 #define FORTRAN_TOOLS_CROSS_TOOL_HELPERS_H
 
-#include "flang/Support/MathOptionsBase.h"
 #include "flang/Frontend/CodeGenOptions.h"
 #include "flang/Frontend/LangOptions.h"
+#include "flang/Support/MathOptionsBase.h"
 #include <cstdint>
 
 #include "mlir/Dialect/OpenMP/OpenMPDialect.h"
diff --git a/flang/lib/Common/CMakeLists.txt b/flang/lib/Common/CMakeLists.txt
index b62aeb2c08b779..73af3bdd589162 100644
--- a/flang/lib/Common/CMakeLists.txt
+++ b/flang/lib/Common/CMakeLists.txt
@@ -1,11 +1,3 @@
-#===-- FortranRuntime/lib/Common/CMakeLists.txt ---------------------------===#
-#
-# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-# See https://llvm.org/LICENSE.txt for license information.
-# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-#
-#===------------------------------------------------------------------------===#
-
 add_flang_library(FortranCommon 
   "${CMAKE_CURRENT_SOURCE_DIR}/../../../FortranRuntime/lib/Common/binary-to-decimal.cpp"
   "${CMAKE_CURRENT_SOURCE_DIR}/../../../FortranRuntime/lib/Common/decimal-to-binary.cpp"
diff --git a/flang/lib/Evaluate/call.cpp b/flang/lib/Evaluate/call.cpp
index 1cb8eb89f41687..f77df92a7597ab 100644
--- a/flang/lib/Evaluate/call.cpp
+++ b/flang/lib/Evaluate/call.cpp
@@ -7,13 +7,13 @@
 //===----------------------------------------------------------------------===//
 
 #include "flang/Evaluate/call.h"
-#include "flang/Support/Fortran.h"
 #include "flang/Common/idioms.h"
 #include "flang/Evaluate/characteristics.h"
 #include "flang/Evaluate/check-expression.h"
 #include "flang/Evaluate/expression.h"
 #include "flang/Evaluate/tools.h"
 #include "flang/Semantics/symbol.h"
+#include "flang/Support/Fortran.h"
 
 namespace Fortran::evaluate {
 
diff --git a/flang/lib/Evaluate/characteristics.cpp b/flang/lib/Evaluate/characteristics.cpp
index 091f2e2b553e86..ffa3ec721cbd63 100644
--- a/flang/lib/Evaluate/characteristics.cpp
+++ b/flang/lib/Evaluate/characteristics.cpp
@@ -7,7 +7,6 @@
 //===----------------------------------------------------------------------===//
 
 #include "flang/Evaluate/characteristics.h"
-#include "flang/Support/indirection.h"
 #include "flang/Evaluate/check-expression.h"
 #include "flang/Evaluate/fold.h"
 #include "flang/Evaluate/intrinsics.h"
@@ -17,6 +16,7 @@
 #include "flang/Semantics/scope.h"
 #include "flang/Semantics/symbol.h"
 #include "flang/Semantics/tools.h"
+#include "flang/Support/indirection.h"
 #include "llvm/Support/raw_ostream.h"
 #include <initializer_list>
 
diff --git a/flang/lib/Evaluate/common.cpp b/flang/lib/Evaluate/common.cpp
index 7741bec650575d..ed040b0728c4db 100644
--- a/flang/lib/Evaluate/common.cpp
+++ b/flang/lib/Evaluate/common.cpp
@@ -9,7 +9,6 @@
 #include "flang/Evaluate/common.h"
 #include "flang/Common/idioms.h"
 
-
 using namespace Fortran::parser::literals;
 
 
diff --git a/flang/lib/Evaluate/fold-implementation.h b/flang/lib/Evaluate/fold-implementation.h
index c8452cdd6a0caa..86cbd971aebcb5 100644
--- a/flang/lib/Evaluate/fold-implementation.h
+++ b/flang/lib/Evaluate/fold-implementation.h
@@ -12,9 +12,6 @@
 #include "character.h"
 #include "host.h"
 #include "int-power.h"
-#include "flang/Support/indirection.h"
-#include "flang/Support/template.h"
-#include "flang/Support/unwrap.h"
 #include "flang/Evaluate/characteristics.h"
 #include "flang/Evaluate/common.h"
 #include "flang/Evaluate/constant.h"
@@ -31,6 +28,9 @@
 #include "flang/Semantics/scope.h"
 #include "flang/Semantics/symbol.h"
 #include "flang/Semantics/tools.h"
+#include "flang/Support/indirection.h"
+#include "flang/Support/template.h"
+#include "flang/Support/unwrap.h"
 #include <algorithm>
 #include <cmath>
 #include <complex>
diff --git a/flang/lib/Evaluate/formatting.cpp b/flang/lib/Evaluate/formatting.cpp
index db5d005d97c8c9..a53fa019984b43 100644
--- a/flang/lib/Evaluate/formatting.cpp
+++ b/flang/lib/Evaluate/formatting.cpp
@@ -7,7 +7,6 @@
 //===----------------------------------------------------------------------===//
 
 #include "flang/Evaluate/formatting.h"
-#include "flang/Support/Fortran.h"
 #include "flang/Evaluate/call.h"
 #include "flang/Evaluate/constant.h"
 #include "flang/Evaluate/expression.h"
@@ -16,6 +15,7 @@
 #include "flang/Parser/characters.h"
 #include "flang/Semantics/semantics.h"
 #include "flang/Semantics/symbol.h"
+#include "flang/Support/Fortran.h"
 #include "llvm/Support/raw_ostream.h"
 
 namespace Fortran::evaluate {
diff --git a/flang/lib/Evaluate/intrinsics-library.cpp b/flang/lib/Evaluate/intrinsics-library.cpp
index 440ddaaf9689c8..4f1eff492afae5 100644
--- a/flang/lib/Evaluate/intrinsics-library.cpp
+++ b/flang/lib/Evaluate/intrinsics-library.cpp
@@ -14,8 +14,8 @@
 #include "flang/Evaluate/intrinsics-library.h"
 #include "fold-implementation.h"
 #include "host.h"
-#include "flang/Support/static-multimap-view.h"
 #include "flang/Evaluate/expression.h"
+#include "flang/Support/static-multimap-view.h"
 #include <cfloat>
 #include <cmath>
 #include <complex>
diff --git a/flang/lib/Evaluate/intrinsics.cpp b/flang/lib/Evaluate/intrinsics.cpp
index 343bd2c9f22be2..bcad2d831cb784 100644
--- a/flang/lib/Evaluate/intrinsics.cpp
+++ b/flang/lib/Evaluate/intrinsics.cpp
@@ -7,7 +7,6 @@
 //===----------------------------------------------------------------------===//
 
 #include "flang/Evaluate/intrinsics.h"
-#include "flang/Support/Fortran.h"
 #include "flang/Common/enum-set.h"
 #include "flang/Common/idioms.h"
 #include "flang/Evaluate/check-expression.h"
@@ -19,6 +18,7 @@
 #include "flang/Evaluate/type.h"
 #include "flang/Semantics/scope.h"
 #include "flang/Semantics/tools.h"
+#include "flang/Support/Fortran.h"
 #include "llvm/Support/raw_ostream.h"
 #include <algorithm>
 #include <cmath>
diff --git a/flang/lib/Evaluate/real.cpp b/flang/lib/Evaluate/real.cpp
index 9d465e5f35d6ae..01d2e14cbf933e 100644
--- a/flang/lib/Evaluate/real.cpp
+++ b/flang/lib/Evaluate/real.cpp
@@ -8,8 +8,8 @@
 
 #include "flang/Evaluate/real.h"
 #include "int-power.h"
-#include "flang/Common/idioms.h"
 #include "flang/Common/decimal.h"
+#include "flang/Common/idioms.h"
 #include "flang/Parser/characters.h"
 #include "llvm/Support/raw_ostream.h"
 #include <limits>
diff --git a/flang/lib/Evaluate/shape.cpp b/flang/lib/Evaluate/shape.cpp
index 7b78d8c7b9734f..d77dd312eba97a 100644
--- a/flang/lib/Evaluate/shape.cpp
+++ b/flang/lib/Evaluate/shape.cpp
@@ -8,7 +8,6 @@
 
 #include "flang/Evaluate/shape.h"
 #include "flang/Common/idioms.h"
-#include "flang/Support/template.h"
 #include "flang/Evaluate/characteristics.h"
 #include "flang/Evaluate/check-expression.h"
 #include "flang/Evaluate/fold.h"
@@ -17,6 +16,7 @@
 #include "flang/Evaluate/type.h"
 #include "flang/Parser/message.h"
 #include "flang/Semantics/symbol.h"
+#include "flang/Support/template.h"
 #include <functional>
 
 using namespace std::placeholders; // _1, _2, &c. for std::bind()
diff --git a/flang/lib/Evaluate/target.cpp b/flang/lib/Evaluate/target.cpp
index d0722c31e3c3f7..79d260af6d50b9 100644
--- a/flang/lib/Evaluate/target.cpp
+++ b/flang/lib/Evaluate/target.cpp
@@ -7,9 +7,9 @@
 //===----------------------------------------------------------------------===//
 
 #include "flang/Evaluate/target.h"
-#include "flang/Support/template.h"
 #include "flang/Evaluate/common.h"
 #include "flang/Evaluate/type.h"
+#include "flang/Support/template.h"
 
 namespace Fortran::evaluate {
 
diff --git a/flang/lib/Frontend/CompilerInstance.cpp b/flang/lib/Frontend/CompilerInstance.cpp
index a0653576852101..d86d6e678a4ed9 100644
--- a/flang/lib/Frontend/CompilerInstance.cpp
+++ b/flang/lib/Frontend/CompilerInstance.cpp
@@ -11,12 +11,12 @@
 //===----------------------------------------------------------------------===//
 
 #include "flang/Frontend/CompilerInstance.h"
-#include "flang/Support/Fortran-features.h"
 #include "flang/Frontend/CompilerInvocation.h"
 #include "flang/Frontend/TextDiagnosticPrinter.h"
 #include "flang/Parser/parsing.h"
 #include "flang/Parser/provenance.h"
 #include "flang/Semantics/semantics.h"
+#include "flang/Support/Fortran-features.h"
 #include "clang/Basic/DiagnosticFrontend.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/MC/TargetRegistry.h"
diff --git a/flang/lib/Frontend/CompilerInvocation.cpp b/flang/lib/Frontend/CompilerInvocation.cpp
index 5fe6ccbc44a894..5416234ca3e9e6 100644
--- a/flang/lib/Frontend/CompilerInvocation.cpp
+++ b/flang/lib/Frontend/CompilerInvocation.cpp
@@ -11,13 +11,13 @@
 //===----------------------------------------------------------------------===//
 
 #include "flang/Frontend/CompilerInvocation.h"
-#include "flang/Support/Fortran-features.h"
-#include "flang/Support/OpenMP-features.h"
-#include "flang/Support/Version.h"
 #include "flang/Frontend/CodeGenOptions.h"
 #include "flang/Frontend/PreprocessorOptions.h"
 #include "flang/Frontend/TargetOptions.h"
 #include "flang/Semantics/semantics.h"
+#include "flang/Support/Fortran-features.h"
+#include "flang/Support/OpenMP-features.h"
+#include "flang/Support/Version.h"
 #include "flang/Tools/TargetSetup.h"
 #include "flang/Version.inc"
 #include "clang/Basic/AllDiagnostics.h"
diff --git a/flang/lib/Frontend/FrontendActions.cpp b/flang/lib/Frontend/FrontendActions.cpp
index 7d51c20514387a..dced7f296e7904 100644
--- a/flang/lib/Frontend/FrontendActions.cpp
+++ b/flang/lib/Frontend/FrontendActions.cpp
@@ -11,7 +11,6 @@
 //===----------------------------------------------------------------------===//
 
 #include "flang/Frontend/FrontendActions.h"
-#include "flang/Support/default-kinds.h"
 #include "flang/Frontend/CompilerInstance.h"
 #include "flang/Frontend/CompilerInvocation.h"
 #include "flang/Frontend/FrontendOptions.h"
@@ -33,6 +32,7 @@
 #include "flang/Semantics/runtime-type-info.h"
 #include "flang/Semantics/semantics.h"
 #include "flang/Semantics/unparse-with-symbols.h"
+#include "flang/Support/default-kinds.h"
 #include "flang/Tools/CrossToolHelpers.h"
 
 #include "mlir/IR/Dialect.h"
diff --git a/flang/lib/Lower/Bridge.cpp b/flang/lib/Lower/Bridge.cpp
index 6924717cb467ac..c903c2169e4dcd 100644
--- a/flang/lib/Lower/Bridge.cpp
+++ b/flang/lib/Lower/Bridge.cpp
@@ -12,7 +12,6 @@
 
 #include "flang/Lower/Bridge.h"
 #include "DirectivesCommon.h"
-#include "flang/Support/Version.h"
 #include "flang/Lower/Allocatable.h"
 #include "flang/Lower/CallInterface.h"
 #include "flang/Lower/Coarray.h"
@@ -59,6 +58,7 @@
 #include "flang/Semantics/runtime-type-info.h"
 #include "flang/Semantics/symbol.h"
 #include "flang/Semantics/tools.h"
+#include "flang/Support/Version.h"
 #include "mlir/Dialect/ControlFlow/IR/ControlFlowOps.h"
 #include "mlir/IR/Matchers.h"
 #include "mlir/IR/PatternMatch.h"
diff --git a/flang/lib/Lower/CallInterface.cpp b/flang/lib/Lower/CallInterface.cpp
index 153845699dae3d..9334ce009eae5e 100644
--- a/flang/lib/Lower/CallInterface.cpp
+++ b/flang/lib/Lower/CallInterface.cpp
@@ -7,7 +7,6 @@
 //===----------------------------------------------------------------------===//
 
 #include "flang/Lower/CallInterface.h"
-#include "flang/Support/Fortran.h"
 #include "flang/Evaluate/fold.h"
 #include "flang/Lower/Bridge.h"
 #include "flang/Lower/Mangler.h"
@@ -23,6 +22,7 @@
 #include "flang/Optimizer/Support/Utils.h"
 #include "flang/Semantics/symbol.h"
 #include "flang/Semantics/tools.h"
+#include "flang/Support/Fortran.h"
 #include <optional>
 
 static mlir::FunctionType
diff --git a/flang/lib/Lower/ConvertExpr.cpp b/flang/lib/Lower/ConvertExpr.cpp
index 4d2ac95ea784b5..b85043f78884f0 100644
--- a/flang/lib/Lower/ConvertExpr.cpp
+++ b/flang/lib/Lower/ConvertExpr.cpp
@@ -11,8 +11,6 @@
 //===----------------------------------------------------------------------===//
 
 #include "flang/Lower/ConvertExpr.h"
-#include "flang/Support/default-kinds.h"
-#include "flang/Support/unwrap.h"
 #include "flang/Evaluate/fold.h"
 #include "flang/Evaluate/real.h"
 #include "flang/Evaluate/traverse.h"
@@ -52,6 +50,8 @@
 #include "flang/Semantics/symbol.h"
 #include "flang/Semantics/tools.h"
 #include "flang/Semantics/type.h"
+#include "flang/Support/default-kinds.h"
+#include "flang/Support/unwrap.h"
 #include "mlir/Dialect/Func/IR/FuncOps.h"
 #include "llvm/ADT/TypeSwitch.h"
 #include "llvm/Support/CommandLine.h"
diff --git a/flang/lib/Lower/Mangler.cpp b/flang/lib/Lower/Mangler.cpp
index 565f9c6cbc5892..4ff170c19d922a 100644
--- a/flang/lib/Lower/Mangler.cpp
+++ b/flang/lib/Lower/Mangler.cpp
@@ -7,12 +7,12 @@
 //===----------------------------------------------------------------------===//
 
 #include "flang/Lower/Mangler.h"
-#include "flang/Support/reference.h"
 #include "flang/Lower/Support/Utils.h"
 #include "flang/Optimizer/Builder/Todo.h"
 #include "flang/Optimizer/Dialect/FIRType.h"
 #include "flang/Optimizer/Support/InternalNames.h"
 #include "flang/Semantics/tools.h"
+#include "flang/Support/reference.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringRef.h"
diff --git a/flang/lib/Optimizer/Builder/IntrinsicCall.cpp b/flang/lib/Optimizer/Builder/IntrinsicCall.cpp
index 5f1a25b1af23e9..460923bbccc27a 100644
--- a/flang/lib/Optimizer/Builder/IntrinsicCall.cpp
+++ b/flang/lib/Optimizer/Builder/IntrinsicCall.cpp
@@ -14,7 +14,6 @@
 //===----------------------------------------------------------------------===//
 
 #include "flang/Optimizer/Builder/IntrinsicCall.h"
-#include "flang/Support/static-multimap-view.h"
 #include "flang/Optimizer/Builder/BoxValue.h"
 #include "flang/Optimizer/Builder/Character.h"
 #include "flang/Optimizer/Builder/Complex.h"
@@ -42,6 +41,7 @@
 #include "flang/Optimizer/Support/Utils.h"
 #include "flang/Runtime/entry-names.h"
 #include "flang/Runtime/iostat.h"
+#include "flang/Support/static-multimap-view.h"
 #include "mlir/Dialect/Complex/IR/Complex.h"
 #include "mlir/Dialect/LLVMIR/LLVMDialect.h"
 #include "mlir/Dialect/Math/IR/Math.h"
@@ -507,7 +507,7 @@ static constexpr IntrinsicHandler handlers[]{
      /*isElemental=*/false},
     {"not", &I::genNot},
     {"null", &I::genNull, {{{"mold", asInquired}}}, /*isElemental=*/false},
-        {"numeric_storage_size", &I::genNumericStorageSize},
+    {"numeric_storage_size", &I::genNumericStorageSize},
     {"pack",
      &I::genPack,
      {{{"array", asBox},
@@ -7224,8 +7224,7 @@ IntrinsicLibrary::genVerify(mlir::Type resultType,
   return readAndAddCleanUp(resultMutableBox, resultType, "VERIFY");
 }
 
-
-    fir::ExtendedValue IntrinsicLibrary:: genNumericStorageSize(mlir::Type resultType, llvm::ArrayRef<fir::ExtendedValue> args) {
+fir::ExtendedValue IntrinsicLibrary:: genNumericStorageSize(mlir::Type resultType, llvm::ArrayRef<fir::ExtendedValue> args) {
       assert(args.empty() );
      
       if (!ignoreModuleOnlyBuiltins) {
@@ -7236,7 +7235,6 @@ IntrinsicLibrary::genVerify(mlir::Type resultType,
       return builder.createIntegerConstant(loc, resultType  , 32 );
     }
 
-
 /// Process calls to Minloc, Maxloc intrinsic functions
 template <typename FN, typename FD>
 fir::ExtendedValue
diff --git a/flang/lib/Optimizer/CodeGen/TypeConverter.cpp b/flang/lib/Optimizer/CodeGen/TypeConverter.cpp
index c632e42ef72c29..45354e0fe79666 100644
--- a/flang/lib/Optimizer/CodeGen/TypeConverter.cpp
+++ b/flang/lib/Optimizer/CodeGen/TypeConverter.cpp
@@ -13,7 +13,6 @@
 #define DEBUG_TYPE "flang-type-conversion"
 
 #include "flang/Optimizer/CodeGen/TypeConverter.h"
-#include "flang/Support/Fortran.h"
 #include "flang/Optimizer/Builder/Todo.h" // remove when TODO's are done
 #include "flang/Optimizer/CodeGen/DescriptorModel.h"
 #include "flang/Optimizer/CodeGen/TBAABuilder.h"
@@ -22,6 +21,7 @@
 #include "flang/Optimizer/Dialect/Support/FIRContext.h"
 #include "flang/Optimizer/Dialect/Support/KindMapping.h"
 #include "flang/Optimizer/Support/InternalNames.h"
+#include "flang/Support/Fortran.h"
 #include "mlir/Conversion/LLVMCommon/TypeConverter.h"
 #include "llvm/ADT/ScopeExit.h"
 #include "llvm/Support/Debug.h"
diff --git a/flang/lib/Optimizer/Transforms/AddDebugInfo.cpp b/flang/lib/Optimizer/Transforms/AddDebugInfo.cpp
index f41633629bb3e2..f84dd6bf6c06c5 100644
--- a/flang/lib/Optimizer/Transforms/AddDebugInfo.cpp
+++ b/flang/lib/Optimizer/Transforms/AddDebugInfo.cpp
@@ -12,7 +12,6 @@
 //===----------------------------------------------------------------------===//
 
 #include "DebugTypeGenerator.h"
-#include "flang/Support/Version.h"
 #include "flang/Optimizer/Builder/FIRBuilder.h"
 #include "flang/Optimizer/Builder/Todo.h"
 #include "flang/Optimizer/CodeGen/CGOps.h"
@@ -22,6 +21,7 @@
 #include "flang/Optimizer/Dialect/Support/FIRContext.h"
 #include "flang/Optimizer/Support/InternalNames.h"
 #include "flang/Optimizer/Transforms/Passes.h"
+#include "flang/Support/Version.h"
 #include "mlir/Dialect/Func/IR/FuncOps.h"
 #include "mlir/Dialect/LLVMIR/LLVMDialect.h"
 #include "mlir/IR/Matchers.h"
diff --git a/flang/lib/Optimizer/Transforms/AssumedRankOpConversion.cpp b/flang/lib/Optimizer/Transforms/AssumedRankOpConversion.cpp
index ca6eacfd0e7200..9fccbd24a74982 100644
--- a/flang/lib/Optimizer/Transforms/AssumedRankOpConversion.cpp
+++ b/flang/lib/Optimizer/Transforms/AssumedRankOpConversion.cpp
@@ -6,7 +6,6 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "flang/Support/Fortran.h"
 #include "flang/Lower/BuiltinModules.h"
 #include "flang/Optimizer/Builder/FIRBuilder.h"
 #include "flang/Optimizer/Builder/Runtime/Support.h"
@@ -17,6 +16,7 @@
 #include "flang/Optimizer/Support/Utils.h"
 #include "flang/Optimizer/Transforms/Passes.h"
 #include "flang/Runtime/support.h"
+#include "flang/Support/Fortran.h"
 #include "mlir/Dialect/Func/IR/FuncOps.h"
 #include "mlir/Pass/Pass.h"
 #include "mlir/Transforms/DialectConversion.h"
diff --git a/flang/lib/Optimizer/Transforms/CufOpConversion.cpp b/flang/lib/Optimizer/Transforms/CufOpConversion.cpp
index d3c44a75e4cffb..d7d321c6b9af3f 100644
--- a/flang/lib/Optimizer/Transforms/CufOpConversion.cpp
+++ b/flang/lib/Optimizer/Transforms/CufOpConversion.cpp
@@ -6,7 +6,6 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "flang/Support/Fortran.h"
 #include "flang/Optimizer/Builder/Runtime/RTBuilder.h"
 #include "flang/Optimizer/CodeGen/TypeConverter.h"
 #include "flang/Optimizer/Dialect/CUF/CUFOps.h"
@@ -16,6 +15,7 @@
 #include "flang/Optimizer/Support/DataLayout.h"
 #include "flang/Runtime/CUDA/descriptor.h"
 #include "flang/Runtime/allocatable.h"
+#include "flang/Support/Fortran.h"
 #include "mlir/Pass/Pass.h"
 #include "mlir/Transforms/DialectConversion.h"
 #include "mlir/Transforms/GreedyPatternRewriteDriver.h"
diff --git a/flang/lib/Optimizer/Transforms/ExternalNameConversion.cpp b/flang/lib/Optimizer/Transforms/ExternalNameConversion.cpp
index 1915abe2f91e0e..3e4f46297357f9 100644
--- a/flang/lib/Optimizer/Transforms/ExternalNameConversion.cpp
+++ b/flang/lib/Optimizer/Transforms/ExternalNameConversion.cpp
@@ -6,12 +6,12 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "flang/Support/Fortran.h"
 #include "flang/Optimizer/Dialect/FIRDialect.h"
 #include "flang/Optimizer/Dialect/FIROps.h"
 #include "flang/Optimizer/Dialect/FIROpsSupport.h"
 #include "flang/Optimizer/Support/InternalNames.h"
 #include "flang/Optimizer/Transforms/Passes.h"
+#include "flang/Support/Fortran.h"
 #include "mlir/IR/Attributes.h"
 #include "mlir/IR/SymbolTable.h"
 #include "mlir/Pass/Pass.h"
diff --git a/flang/lib/Optimizer/Transforms/SimplifyIntrinsics.cpp b/flang/lib/Optimizer/Transforms/SimplifyIntrinsics.cpp
index c56dfa1cdfb524..3f5178710689cb 100644
--- a/flang/lib/Optimizer/Transforms/SimplifyIntrinsics.cpp
+++ b/flang/lib/Optimizer/Transforms/SimplifyIntrinsics.cpp
@@ -22,7 +22,6 @@
 /// and small in size.
 //===----------------------------------------------------------------------===//
 
-#include "flang/Support/Fortran.h"
 #include "flang/Optimizer/Builder/BoxValue.h"
 #include "flang/Optimizer/Builder/FIRBuilder.h"
 #include "flang/Optimizer/Builder/LowLevelIntrinsics.h"
@@ -34,6 +33,7 @@
 #include "flang/Optimizer/Transforms/Passes.h"
 #include "flang/Optimizer/Transforms/Utils.h"
 #include "flang/Runtime/entry-names.h"
+#include "flang/Support/Fortran.h"
 #include "mlir/Dialect/LLVMIR/LLVMDialect.h"
 #include "mlir/IR/Matchers.h"
 #include "mlir/IR/Operation.h"
diff --git a/flang/lib/Optimizer/Transforms/StackReclaim.cpp b/flang/lib/Optimizer/Transforms/StackReclaim.cpp
index 629ba587adf3ca..eb088c30e94f20 100644
--- a/flang/lib/Optimizer/Transforms/StackReclaim.cpp
+++ b/flang/lib/Optimizer/Transforms/StackReclaim.cpp
@@ -6,10 +6,10 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "flang/Support/Fortran.h"
 #include "flang/Optimizer/Dialect/FIRDialect.h"
 #include "flang/Optimizer/Dialect/FIROps.h"
 #include "flang/Optimizer/Transforms/Passes.h"
+#include "flang/Support/Fortran.h"
 #include "mlir/Dialect/LLVMIR/LLVMDialect.h"
 #include "mlir/IR/Matchers.h"
 #include "mlir/Pass/Pass.h"
diff --git a/flang/lib/Parser/basic-parsers.h b/flang/lib/Parser/basic-parsers.h
index 6575c7d01de346..be0f4fc44374ca 100644
--- a/flang/lib/Parser/basic-parsers.h
+++ b/flang/lib/Parser/basic-parsers.h
@@ -22,14 +22,14 @@
 // This header defines the fundamental parser class templates and helper
 // template functions.  See parser-combinators.txt for documentation.
 
-#include "flang/Support/Fortran-features.h"
 #include "flang/Common/idioms.h"
-#include "flang/Support/indirection.h"
 #include "flang/Parser/char-block.h"
 #include "flang/Parser/message.h"
 #include "flang/Parser/parse-state.h"
 #include "flang/Parser/provenance.h"
 #include "flang/Parser/user-state.h"
+#include "flang/Support/Fortran-features.h"
+#include "flang/Support/indirection.h"
 #include <cstring>
 #include <functional>
 #include <list>
diff --git a/flang/lib/Parser/parse-tree.cpp b/flang/lib/Parser/parse-tree.cpp
index 3b90a57c602945..0793383efefb5f 100644
--- a/flang/lib/Parser/parse-tree.cpp
+++ b/flang/lib/Parser/parse-tree.cpp
@@ -8,9 +8,9 @@
 
 #include "flang/Parser/parse-tree.h"
 #include "flang/Common/idioms.h"
-#include "flang/Support/indirection.h"
 #include "flang/Parser/tools.h"
 #include "flang/Parser/user-state.h"
+#include "flang/Support/indirection.h"
 #include "llvm/Support/raw_ostream.h"
 #include <algorithm>
 
diff --git a/flang/lib/Parser/prescan.h b/flang/lib/Parser/prescan.h
index 0ea614d1df3bd9..f9d920a6621aa5 100644
--- a/flang/lib/Parser/prescan.h
+++ b/flang/lib/Parser/prescan.h
@@ -16,11 +16,11 @@
 // fixed form character literals on truncated card images, file
 // inclusion, and driving the Fortran source preprocessor.
 
-#include "flang/Support/Fortran-features.h"
 #include "flang/Parser/characters.h"
 #include "flang/Parser/message.h"
 #include "flang/Parser/provenance.h"
 #include "flang/Parser/token-sequence.h"
+#include "flang/Support/Fortran-features.h"
 #include <bitset>
 #include <optional>
 #include <string>
diff --git a/flang/lib/Parser/unparse.cpp b/flang/lib/Parser/unparse.cpp
index 7b0385c63cd8a1..4a044514916030 100644
--- a/flang/lib/Parser/unparse.cpp
+++ b/flang/lib/Parser/unparse.cpp
@@ -10,13 +10,13 @@
 // traversal templates in parse-tree-visitor.h.
 
 #include "flang/Parser/unparse.h"
-#include "flang/Support/Fortran.h"
 #include "flang/Common/idioms.h"
-#include "flang/Support/indirection.h"
 #include "flang/Parser/characters.h"
 #include "flang/Parser/parse-tree-visitor.h"
 #include "flang/Parser/parse-tree.h"
 #include "flang/Parser/tools.h"
+#include "flang/Support/Fortran.h"
+#include "flang/Support/indirection.h"
 #include "llvm/Support/raw_ostream.h"
 #include <algorithm>
 #include <cinttypes>
diff --git a/flang/lib/Semantics/assignment.h b/flang/lib/Semantics/assignment.h
index 275625d3ed6522..ba0c70f7d224cb 100644
--- a/flang/lib/Semantics/assignment.h
+++ b/flang/lib/Semantics/assignment.h
@@ -9,9 +9,9 @@
 #ifndef FORTRAN_SEMANTICS_ASSIGNMENT_H_
 #define FORTRAN_SEMANTICS_ASSIGNMENT_H_
 
-#include "flang/Support/indirection.h"
 #include "flang/Evaluate/expression.h"
 #include "flang/Semantics/semantics.h"
+#include "flang/Support/indirection.h"
 
 namespace Fortran::parser {
 class ContextualMessages;
diff --git a/flang/lib/Semantics/check-case.cpp b/flang/lib/Semantics/check-case.cpp
index 0e38b24f1b319d..6d38bbee1eb2cb 100644
--- a/flang/lib/Semantics/check-case.cpp
+++ b/flang/lib/Semantics/check-case.cpp
@@ -8,13 +8,13 @@
 
 #include "check-case.h"
 #include "flang/Common/idioms.h"
-#include "flang/Support/reference.h"
-#include "flang/Support/template.h"
 #include "flang/Evaluate/fold.h"
 #include "flang/Evaluate/type.h"
 #include "flang/Parser/parse-tree.h"
 #include "flang/Semantics/semantics.h"
 #include "flang/Semantics/tools.h"
+#include "flang/Support/reference.h"
+#include "flang/Support/template.h"
 #include <tuple>
 
 namespace Fortran::semantics {
diff --git a/flang/lib/Semantics/check-coarray.cpp b/flang/lib/Semantics/check-coarray.cpp
index d34c70e60d966b..ac1f38801cee72 100644
--- a/flang/lib/Semantics/check-coarray.cpp
+++ b/flang/lib/Semantics/check-coarray.cpp
@@ -7,13 +7,13 @@
 //===----------------------------------------------------------------------===//
 
 #include "check-coarray.h"
-#include "flang/Support/indirection.h"
 #include "flang/Evaluate/expression.h"
 #include "flang/Parser/message.h"
 #include "flang/Parser/parse-tree.h"
 #include "flang/Parser/tools.h"
 #include "flang/Semantics/expression.h"
 #include "flang/Semantics/tools.h"
+#include "flang/Support/indirection.h"
 
 namespace Fortran::semantics {
 
diff --git a/flang/lib/Semantics/check-cuda.cpp b/flang/lib/Semantics/check-cuda.cpp
index 738a471f4d01f5..b89b46868d2e58 100644
--- a/flang/lib/Semantics/check-cuda.cpp
+++ b/flang/lib/Semantics/check-cuda.cpp
@@ -7,7 +7,6 @@
 //===----------------------------------------------------------------------===//
 
 #include "check-cuda.h"
-#include "flang/Support/template.h"
 #include "flang/Evaluate/fold.h"
 #include "flang/Evaluate/tools.h"
 #include "flang/Evaluate/traverse.h"
@@ -17,6 +16,7 @@
 #include "flang/Semantics/expression.h"
 #include "flang/Semantics/symbol.h"
 #include "flang/Semantics/tools.h"
+#include "flang/Support/template.h"
 
 // Once labeled DO constructs have been canonicalized and their parse subtrees
 // transformed into parser::DoConstructs, scan the parser::Blocks of the program
diff --git a/flang/lib/Semantics/check-data.h b/flang/lib/Semantics/check-data.h
index 5cdf46a5ffb1c9..6da316cccc4a7b 100644
--- a/flang/lib/Semantics/check-data.h
+++ b/flang/lib/Semantics/check-data.h
@@ -10,11 +10,11 @@
 #define FORTRAN_SEMANTICS_CHECK_DATA_H_
 
 #include "data-to-inits.h"
-#include "flang/Support/interval.h"
 #include "flang/Evaluate/fold-designator.h"
 #include "flang/Evaluate/initial-image.h"
 #include "flang/Semantics/expression.h"
 #include "flang/Semantics/semantics.h"
+#include "flang/Support/interval.h"
 #include <list>
 #include <map>
 #include <vector>
diff --git a/flang/lib/Semantics/check-do-forall.cpp b/flang/lib/Semantics/check-do-forall.cpp
index 42e1c07fc45c3e..26530e798c9f4c 100644
--- a/flang/lib/Semantics/check-do-forall.cpp
+++ b/flang/lib/Semantics/check-do-forall.cpp
@@ -8,7 +8,6 @@
 
 #include "check-do-forall.h"
 #include "definable.h"
-#include "flang/Support/template.h"
 #include "flang/Evaluate/call.h"
 #include "flang/Evaluate/expression.h"
 #include "flang/Evaluate/tools.h"
@@ -22,6 +21,7 @@
 #include "flang/Semantics/symbol.h"
 #include "flang/Semantics/tools.h"
 #include "flang/Semantics/type.h"
+#include "flang/Support/template.h"
 
 namespace Fortran::evaluate {
 using ActualArgumentRef = common::Reference<const ActualArgument>;
diff --git a/flang/lib/Semantics/check-return.cpp b/flang/lib/Semantics/check-return.cpp
index 6a03467a27a759..c7b91a2725c942 100644
--- a/flang/lib/Semantics/check-return.cpp
+++ b/flang/lib/Semantics/check-return.cpp
@@ -7,11 +7,11 @@
 //===----------------------------------------------------------------------===//
 
 #include "check-return.h"
-#include "flang/Support/Fortran-features.h"
 #include "flang/Parser/message.h"
 #include "flang/Parser/parse-tree.h"
 #include "flang/Semantics/semantics.h"
 #include "flang/Semantics/tools.h"
+#include "flang/Support/Fortran-features.h"
 
 namespace Fortran::semantics {
 
diff --git a/flang/lib/Semantics/check-select-rank.cpp b/flang/lib/Semantics/check-select-rank.cpp
index 722226465b6642..b227bbaaef4ba4 100644
--- a/flang/lib/Semantics/check-select-rank.cpp
+++ b/flang/lib/Semantics/check-select-rank.cpp
@@ -7,11 +7,11 @@
 //===----------------------------------------------------------------------===//
 
 #include "check-select-rank.h"
-#include "flang/Support/Fortran.h"
 #include "flang/Common/idioms.h"
 #include "flang/Parser/message.h"
 #include "flang/Parser/tools.h"
 #include "flang/Semantics/tools.h"
+#include "flang/Support/Fortran.h"
 #include <list>
 #include <optional>
 #include <set>
diff --git a/flang/lib/Semantics/check-select-type.cpp b/flang/lib/Semantics/check-select-type.cpp
index da41410bd24612..b86a95492b21c1 100644
--- a/flang/lib/Semantics/check-select-type.cpp
+++ b/flang/lib/Semantics/check-select-type.cpp
@@ -8,12 +8,12 @@
 
 #include "check-select-type.h"
 #include "flang/Common/idioms.h"
-#include "flang/Support/reference.h"
 #include "flang/Evaluate/fold.h"
 #include "flang/Evaluate/type.h"
 #include "flang/Parser/parse-tree.h"
 #include "flang/Semantics/semantics.h"
 #include "flang/Semantics/tools.h"
+#include "flang/Support/reference.h"
 #include <optional>
 
 namespace Fortran::semantics {
diff --git a/flang/lib/Semantics/check-stop.cpp b/flang/lib/Semantics/check-stop.cpp
index dab076424bd8e6..aabd52098e63bb 100644
--- a/flang/lib/Semantics/check-stop.cpp
+++ b/flang/lib/Semantics/check-stop.cpp
@@ -7,11 +7,11 @@
 //===----------------------------------------------------------------------===//
 
 #include "check-stop.h"
-#include "flang/Support/Fortran.h"
 #include "flang/Evaluate/expression.h"
 #include "flang/Parser/parse-tree.h"
 #include "flang/Semantics/semantics.h"
 #include "flang/Semantics/tools.h"
+#include "flang/Support/Fortran.h"
 #include <optional>
 
 namespace Fortran::semantics {
diff --git a/flang/lib/Semantics/data-to-inits.h b/flang/lib/Semantics/data-to-inits.h
index df4d552760eda6..e99a02cc79db15 100644
--- a/flang/lib/Semantics/data-to-inits.h
+++ b/flang/lib/Semantics/data-to-inits.h
@@ -9,10 +9,10 @@
 #ifndef FORTRAN_SEMANTICS_DATA_TO_INITS_H_
 #define FORTRAN_SEMANTICS_DATA_TO_INITS_H_
 
-#include "flang/Support/default-kinds.h"
-#include "flang/Support/interval.h"
 #include "flang/Evaluate/fold-designator.h"
 #include "flang/Evaluate/initial-image.h"
+#include "flang/Support/default-kinds.h"
+#include "flang/Support/interval.h"
 #include <list>
 #include <map>
 
diff --git a/flang/lib/Semantics/expression.cpp b/flang/lib/Semantics/expression.cpp
index a4be06515e4c87..2a8ed892c800eb 100644
--- a/flang/lib/Semantics/expression.cpp
+++ b/flang/lib/Semantics/expression.cpp
@@ -11,7 +11,6 @@
 #include "pointer-assignment.h"
 #include "resolve-names-utils.h"
 #include "resolve-names.h"
-#include "flang/Support/Fortran.h"
 #include "flang/Common/idioms.h"
 #include "flang/Evaluate/common.h"
 #include "flang/Evaluate/fold.h"
@@ -24,6 +23,7 @@
 #include "flang/Semantics/semantics.h"
 #include "flang/Semantics/symbol.h"
 #include "flang/Semantics/tools.h"
+#include "flang/Support/Fortran.h"
 #include "llvm/Support/raw_ostream.h"
 #include <algorithm>
 #include <functional>
diff --git a/flang/lib/Semantics/pointer-assignment.cpp b/flang/lib/Semantics/pointer-assignment.cpp
index abd3c5f461cb7e..d8fcedf24bdb9e 100644
--- a/flang/lib/Semantics/pointer-assignment.cpp
+++ b/flang/lib/Semantics/pointer-assignment.cpp
@@ -10,7 +10,6 @@
 #include "definable.h"
 #include "flang/Common/idioms.h"
 #include "flang/Common/restorer.h"
-#include "flang/Support/template.h"
 #include "flang/Evaluate/characteristics.h"
 #include "flang/Evaluate/expression.h"
 #include "flang/Evaluate/fold.h"
@@ -21,6 +20,7 @@
 #include "flang/Semantics/expression.h"
 #include "flang/Semantics/symbol.h"
 #include "flang/Semantics/tools.h"
+#include "flang/Support/template.h"
 #include "llvm/Support/raw_ostream.h"
 #include <optional>
 #include <set>
diff --git a/flang/lib/Semantics/resolve-labels.cpp b/flang/lib/Semantics/resolve-labels.cpp
index 84d2e51d438bfe..e988ba8e331963 100644
--- a/flang/lib/Semantics/resolve-labels.cpp
+++ b/flang/lib/Semantics/resolve-labels.cpp
@@ -8,9 +8,9 @@
 
 #include "resolve-labels.h"
 #include "flang/Common/enum-set.h"
-#include "flang/Support/template.h"
 #include "flang/Parser/parse-tree-visitor.h"
 #include "flang/Semantics/semantics.h"
+#include "flang/Support/template.h"
 #include <cstdarg>
 #include <type_traits>
 
diff --git a/flang/lib/Semantics/resolve-names-utils.cpp b/flang/lib/Semantics/resolve-names-utils.cpp
index bc5f458f403cf2..3aa48e92d423db 100644
--- a/flang/lib/Semantics/resolve-names-utils.cpp
+++ b/flang/lib/Semantics/resolve-names-utils.cpp
@@ -7,10 +7,7 @@
 //===----------------------------------------------------------------------===//
 
 #include "resolve-names-utils.h"
-#include "flang/Support/Fortran-features.h"
-#include "flang/Support/Fortran.h"
 #include "flang/Common/idioms.h"
-#include "flang/Support/indirection.h"
 #include "flang/Evaluate/fold.h"
 #include "flang/Evaluate/tools.h"
 #include "flang/Evaluate/traverse.h"
@@ -20,6 +17,9 @@
 #include "flang/Semantics/expression.h"
 #include "flang/Semantics/semantics.h"
 #include "flang/Semantics/tools.h"
+#include "flang/Support/Fortran-features.h"
+#include "flang/Support/Fortran.h"
+#include "flang/Support/indirection.h"
 #include <initializer_list>
 #include <variant>
 
diff --git a/flang/lib/Semantics/resolve-names.cpp b/flang/lib/Semantics/resolve-names.cpp
index 920cefa084e05c..ebcb864549e48e 100644
--- a/flang/lib/Semantics/resolve-names.cpp
+++ b/flang/lib/Semantics/resolve-names.cpp
@@ -14,9 +14,6 @@
 #include "resolve-directives.h"
 #include "resolve-names-utils.h"
 #include "rewrite-parse-tree.h"
-#include "flang/Support/Fortran.h"
-#include "flang/Support/default-kinds.h"
-#include "flang/Support/indirection.h"
 #include "flang/Common/restorer.h"
 #include "flang/Common/visit.h"
 #include "flang/Evaluate/characteristics.h"
@@ -37,6 +34,9 @@
 #include "flang/Semantics/symbol.h"
 #include "flang/Semantics/tools.h"
 #include "flang/Semantics/type.h"
+#include "flang/Support/Fortran.h"
+#include "flang/Support/default-kinds.h"
+#include "flang/Support/indirection.h"
 #include "llvm/Support/raw_ostream.h"
 #include <list>
 #include <map>
diff --git a/flang/lib/Semantics/rewrite-parse-tree.cpp b/flang/lib/Semantics/rewrite-parse-tree.cpp
index 46641f5bd3c363..7f4efe67d7ec9f 100644
--- a/flang/lib/Semantics/rewrite-parse-tree.cpp
+++ b/flang/lib/Semantics/rewrite-parse-tree.cpp
@@ -8,7 +8,6 @@
 
 #include "rewrite-parse-tree.h"
 #include "rewrite-directives.h"
-#include "flang/Support/indirection.h"
 #include "flang/Parser/parse-tree-visitor.h"
 #include "flang/Parser/parse-tree.h"
 #include "flang/Parser/tools.h"
@@ -16,6 +15,7 @@
 #include "flang/Semantics/semantics.h"
 #include "flang/Semantics/symbol.h"
 #include "flang/Semantics/tools.h"
+#include "flang/Support/indirection.h"
 #include <list>
 
 namespace Fortran::semantics {
diff --git a/flang/lib/Semantics/semantics.cpp b/flang/lib/Semantics/semantics.cpp
index c39c8ac5a7b111..aa897f3011f51d 100644
--- a/flang/lib/Semantics/semantics.cpp
+++ b/flang/lib/Semantics/semantics.cpp
@@ -37,12 +37,12 @@
 #include "resolve-labels.h"
 #include "resolve-names.h"
 #include "rewrite-parse-tree.h"
-#include "flang/Support/default-kinds.h"
 #include "flang/Parser/parse-tree-visitor.h"
 #include "flang/Parser/tools.h"
 #include "flang/Semantics/expression.h"
 #include "flang/Semantics/scope.h"
 #include "flang/Semantics/symbol.h"
+#include "flang/Support/default-kinds.h"
 #include "llvm/Support/raw_ostream.h"
 #include "llvm/TargetParser/Host.h"
 #include "llvm/TargetParser/Triple.h"
diff --git a/flang/lib/Semantics/tools.cpp b/flang/lib/Semantics/tools.cpp
index 2aa0476b8fa07a..3f5cf3cebbea9b 100644
--- a/flang/lib/Semantics/tools.cpp
+++ b/flang/lib/Semantics/tools.cpp
@@ -7,8 +7,6 @@
 //===----------------------------------------------------------------------===//
 
 #include "flang/Parser/tools.h"
-#include "flang/Support/Fortran.h"
-#include "flang/Support/indirection.h"
 #include "flang/Parser/dump-parse-tree.h"
 #include "flang/Parser/message.h"
 #include "flang/Parser/parse-tree.h"
@@ -17,6 +15,8 @@
 #include "flang/Semantics/symbol.h"
 #include "flang/Semantics/tools.h"
 #include "flang/Semantics/type.h"
+#include "flang/Support/Fortran.h"
+#include "flang/Support/indirection.h"
 #include "llvm/Support/raw_ostream.h"
 #include <algorithm>
 #include <set>
diff --git a/flang/lib/Support/Fortran-features.cpp b/flang/lib/Support/Fortran-features.cpp
index e49735218ab967..868d18caa13c64 100644
--- a/flang/lib/Support/Fortran-features.cpp
+++ b/flang/lib/Support/Fortran-features.cpp
@@ -7,8 +7,8 @@
 //===----------------------------------------------------------------------===//
 
 #include "flang/Support/Fortran-features.h"
-#include "flang/Support/Fortran.h"
 #include "flang/Common/idioms.h"
+#include "flang/Support/Fortran.h"
 
 namespace Fortran::common {
 
diff --git a/flang/lib/Support/big-radix-floating-point.h b/flang/lib/Support/big-radix-floating-point.h
deleted file mode 100644
index 4c3d8f8b30832a..00000000000000
--- a/flang/lib/Support/big-radix-floating-point.h
+++ /dev/null
@@ -1,396 +0,0 @@
-//===-- lib/Support/big-radix-floating-point.h ------------------*- C++ -*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef FORTRAN_DECIMAL_BIG_RADIX_FLOATING_POINT_H_
-#define FORTRAN_DECIMAL_BIG_RADIX_FLOATING_POINT_H_
-
-// This is a helper class for use in floating-point conversions between
-// binary and decimal representations.  It holds a multiple-precision
-// integer value using digits of a radix that is a large even power of ten
-// (10,000,000,000,000,000 by default, 10**16).  These digits are accompanied
-// by a signed exponent that denotes multiplication by a power of ten.
-// The effective radix point is to the right of the digits (i.e., they do
-// not represent a fraction).
-//
-// The operations supported by this class are limited to those required
-// for conversions between binary and decimal representations; it is not
-// a general-purpose facility.
-
-#include "flang/Common/bit-population-count.h"
-#include "flang/Common/leading-zero-bit-count.h"
-#include "flang/Common/uint128.h"
-#include "flang/Support/binary-floating-point.h"
-#include "flang/Common/decimal.h"
-#include <cinttypes>
-#include <limits>
-#include <type_traits>
-
-// Some environments, viz. glibc 2.17, allow the macro HUGE
-// to leak out of <math.h>.
-#undef HUGE
-
-namespace Fortran::decimal {
-
-static constexpr std::uint64_t TenToThe(int power) {
-  return power <= 0 ? 1 : 10 * TenToThe(power - 1);
-}
-
-// 10**(LOG10RADIX + 3) must be < 2**wordbits, and LOG10RADIX must be
-// even, so that pairs of decimal digits do not straddle Digits.
-// So LOG10RADIX must be 16 or 6.
-template <int PREC, int LOG10RADIX = 16> class BigRadixFloatingPointNumber {
-public:
-  using Real = BinaryFloatingPointNumber<PREC>;
-  static constexpr int log10Radix{LOG10RADIX};
-
-private:
-  static constexpr std::uint64_t uint64Radix{TenToThe(log10Radix)};
-  static constexpr int minDigitBits{
-      64 - common::LeadingZeroBitCount(uint64Radix)};
-  using Digit = common::HostUnsignedIntType<minDigitBits>;
-  static constexpr Digit radix{uint64Radix};
-  static_assert(radix < std::numeric_limits<Digit>::max() / 1000,
-      "radix is somehow too big");
-  static_assert(radix > std::numeric_limits<Digit>::max() / 10000,
-      "radix is somehow too small");
-
-  // The base-2 logarithm of the least significant bit that can arise
-  // in a subnormal IEEE floating-point number.
-  static constexpr int minLog2AnyBit{
-      -Real::exponentBias - Real::binaryPrecision};
-
-  // The number of Digits needed to represent the smallest subnormal.
-  static constexpr int maxDigits{3 - minLog2AnyBit / log10Radix};
-
-public:
-  explicit RT_API_ATTRS BigRadixFloatingPointNumber(
-      enum FortranRounding rounding = RoundNearest)
-      : rounding_{rounding} {}
-
-  // Converts a binary floating point value.
-  explicit RT_API_ATTRS BigRadixFloatingPointNumber(
-      Real, enum FortranRounding = RoundNearest);
-
-  RT_API_ATTRS BigRadixFloatingPointNumber &SetToZero() {
-    isNegative_ = false;
-    digits_ = 0;
-    exponent_ = 0;
-    return *this;
-  }
-
-  RT_API_ATTRS bool IsInteger() const { return exponent_ >= 0; }
-
-  // Converts decimal floating-point to binary.
-  RT_API_ATTRS ConversionToBinaryResult<PREC> ConvertToBinary();
-
-  // Parses and converts to binary.  Handles leading spaces,
-  // "NaN", & optionally-signed "Inf".  Does not skip internal
-  // spaces.
-  // The argument is a reference to a pointer that is left
-  // pointing to the first character that wasn't parsed.
-  RT_API_ATTRS ConversionToBinaryResult<PREC> ConvertToBinary(
-      const char *&, const char *end = nullptr);
-
-  // Formats a decimal floating-point number to a user buffer.
-  // May emit "NaN" or "Inf", or an possibly-signed integer.
-  // No decimal point is written, but if it were, it would be
-  // after the last digit; the effective decimal exponent is
-  // returned as part of the result structure so that it can be
-  // formatted by the client.
-  RT_API_ATTRS ConversionToDecimalResult ConvertToDecimal(
-      char *, std::size_t, enum DecimalConversionFlags, int digits) const;
-
-  // Discard decimal digits not needed to distinguish this value
-  // from the decimal encodings of two others (viz., the nearest binary
-  // floating-point numbers immediately below and above this one).
-  // The last decimal digit may not be uniquely determined in all
-  // cases, and will be the mean value when that is so (e.g., if
-  // last decimal digit values 6-8 would all work, it'll be a 7).
-  // This minimization necessarily assumes that the value will be
-  // emitted and read back into the same (or less precise) format
-  // with default rounding to the nearest value.
-  RT_API_ATTRS void Minimize(
-      BigRadixFloatingPointNumber &&less, BigRadixFloatingPointNumber &&more);
-
-  template <typename STREAM> STREAM &Dump(STREAM &) const;
-
-private:
-  RT_API_ATTRS BigRadixFloatingPointNumber(
-      const BigRadixFloatingPointNumber &that)
-      : digits_{that.digits_}, exponent_{that.exponent_},
-        isNegative_{that.isNegative_}, rounding_{that.rounding_} {
-    for (int j{0}; j < digits_; ++j) {
-      digit_[j] = that.digit_[j];
-    }
-  }
-
-  RT_API_ATTRS bool IsZero() const {
-    // Don't assume normalization.
-    for (int j{0}; j < digits_; ++j) {
-      if (digit_[j] != 0) {
-        return false;
-      }
-    }
-    return true;
-  }
-
-  // Predicate: true when 10*value would cause a carry.
-  // (When this happens during decimal-to-binary conversion,
-  // there are more digits in the input string than can be
-  // represented precisely.)
-  RT_API_ATTRS bool IsFull() const {
-    return digits_ == digitLimit_ && digit_[digits_ - 1] >= radix / 10;
-  }
-
-  // Sets *this to an unsigned integer value.
-  // Returns any remainder.
-  template <typename UINT> RT_API_ATTRS UINT SetTo(UINT n) {
-    static_assert(
-        std::is_same_v<UINT, common::uint128_t> || std::is_unsigned_v<UINT>);
-    SetToZero();
-    while (n != 0) {
-      auto q{n / 10u};
-      if (n != q * 10) {
-        break;
-      }
-      ++exponent_;
-      n = q;
-    }
-    if constexpr (sizeof n < sizeof(Digit)) {
-      if (n != 0) {
-        digit_[digits_++] = n;
-      }
-      return 0;
-    } else {
-      while (n != 0 && digits_ < digitLimit_) {
-        auto q{n / radix};
-        digit_[digits_++] = static_cast<Digit>(n - q * radix);
-        n = q;
-      }
-      return n;
-    }
-  }
-
-  RT_API_ATTRS int RemoveLeastOrderZeroDigits() {
-    int remove{0};
-    if (digits_ > 0 && digit_[0] == 0) {
-      while (remove < digits_ && digit_[remove] == 0) {
-        ++remove;
-      }
-      if (remove >= digits_) {
-        digits_ = 0;
-      } else if (remove > 0) {
-#if defined __GNUC__ && __GNUC__ < 8
-        // (&& j + remove < maxDigits) was added to avoid GCC < 8 build failure
-        // on -Werror=array-bounds. This can be removed if -Werror is disable.
-        for (int j{0}; j + remove < digits_ && (j + remove < maxDigits); ++j) {
-#else
-        for (int j{0}; j + remove < digits_; ++j) {
-#endif
-          digit_[j] = digit_[j + remove];
-        }
-        digits_ -= remove;
-      }
-    }
-    return remove;
-  }
-
-  RT_API_ATTRS void RemoveLeadingZeroDigits() {
-    while (digits_ > 0 && digit_[digits_ - 1] == 0) {
-      --digits_;
-    }
-  }
-
-  RT_API_ATTRS void Normalize() {
-    RemoveLeadingZeroDigits();
-    exponent_ += RemoveLeastOrderZeroDigits() * log10Radix;
-  }
-
-  // This limited divisibility test only works for even divisors of the radix,
-  // which is fine since it's only ever used with 2 and 5.
-  template <int N> RT_API_ATTRS bool IsDivisibleBy() const {
-    static_assert(N > 1 && radix % N == 0, "bad modulus");
-    return digits_ == 0 || (digit_[0] % N) == 0;
-  }
-
-  template <unsigned DIVISOR> RT_API_ATTRS int DivideBy() {
-    Digit remainder{0};
-    for (int j{digits_ - 1}; j >= 0; --j) {
-      Digit q{digit_[j] / DIVISOR};
-      Digit nrem{digit_[j] - DIVISOR * q};
-      digit_[j] = q + (radix / DIVISOR) * remainder;
-      remainder = nrem;
-    }
-    return remainder;
-  }
-
-  RT_API_ATTRS void DivideByPowerOfTwo(int twoPow) { // twoPow <= log10Radix
-    Digit remainder{0};
-    auto mask{(Digit{1} << twoPow) - 1};
-    auto coeff{radix >> twoPow};
-    for (int j{digits_ - 1}; j >= 0; --j) {
-      auto nrem{digit_[j] & mask};
-      digit_[j] = (digit_[j] >> twoPow) + coeff * remainder;
-      remainder = nrem;
-    }
-  }
-
-  // Returns true on overflow
-  RT_API_ATTRS bool DivideByPowerOfTwoInPlace(int twoPow) {
-    if (digits_ > 0) {
-      while (twoPow > 0) {
-        int chunk{twoPow > log10Radix ? log10Radix : twoPow};
-        if ((digit_[0] & ((Digit{1} << chunk) - 1)) == 0) {
-          DivideByPowerOfTwo(chunk);
-          twoPow -= chunk;
-          continue;
-        }
-        twoPow -= chunk;
-        if (digit_[digits_ - 1] >> chunk != 0) {
-          if (digits_ == digitLimit_) {
-            return true; // overflow
-          }
-          digit_[digits_++] = 0;
-        }
-        auto remainder{digit_[digits_ - 1]};
-        exponent_ -= log10Radix;
-        auto coeff{radix >> chunk}; // precise; radix is (5*2)**log10Radix
-        auto mask{(Digit{1} << chunk) - 1};
-        for (int j{digits_ - 1}; j >= 1; --j) {
-          digit_[j] = (digit_[j - 1] >> chunk) + coeff * remainder;
-          remainder = digit_[j - 1] & mask;
-        }
-        digit_[0] = coeff * remainder;
-      }
-    }
-    return false; // no overflow
-  }
-
-  RT_API_ATTRS int AddCarry(int position = 0, int carry = 1) {
-    for (; position < digits_; ++position) {
-      Digit v{digit_[position] + carry};
-      if (v < radix) {
-        digit_[position] = v;
-        return 0;
-      }
-      digit_[position] = v - radix;
-      carry = 1;
-    }
-    if (digits_ < digitLimit_) {
-      digit_[digits_++] = carry;
-      return 0;
-    }
-    Normalize();
-    if (digits_ < digitLimit_) {
-      digit_[digits_++] = carry;
-      return 0;
-    }
-    return carry;
-  }
-
-  RT_API_ATTRS void Decrement() {
-    for (int j{0}; digit_[j]-- == 0; ++j) {
-      digit_[j] = radix - 1;
-    }
-  }
-
-  template <int N> RT_API_ATTRS int MultiplyByHelper(int carry = 0) {
-    for (int j{0}; j < digits_; ++j) {
-      auto v{N * digit_[j] + carry};
-      carry = v / radix;
-      digit_[j] = v - carry * radix; // i.e., v % radix
-    }
-    return carry;
-  }
-
-  template <int N> RT_API_ATTRS int MultiplyBy(int carry = 0) {
-    if (int newCarry{MultiplyByHelper<N>(carry)}) {
-      return AddCarry(digits_, newCarry);
-    } else {
-      return 0;
-    }
-  }
-
-  template <int N> RT_API_ATTRS int MultiplyWithoutNormalization() {
-    if (int carry{MultiplyByHelper<N>(0)}) {
-      if (digits_ < digitLimit_) {
-        digit_[digits_++] = carry;
-        return 0;
-      } else {
-        return carry;
-      }
-    } else {
-      return 0;
-    }
-  }
-
-  RT_API_ATTRS void LoseLeastSignificantDigit(); // with rounding
-
-  RT_API_ATTRS void PushCarry(int carry) {
-    if (digits_ == maxDigits && RemoveLeastOrderZeroDigits() == 0) {
-      LoseLeastSignificantDigit();
-      digit_[digits_ - 1] += carry;
-    } else {
-      digit_[digits_++] = carry;
-    }
-  }
-
-  // Adds another number and then divides by two.
-  // Assumes same exponent and sign.
-  // Returns true when the result has effectively been rounded down.
-  RT_API_ATTRS bool Mean(const BigRadixFloatingPointNumber &);
-
-  // Parses a floating-point number; leaves the pointer reference
-  // argument pointing at the next character after what was recognized.
-  // The "end" argument can be left null if the caller is sure that the
-  // string is properly terminated with an addressable character that
-  // can't be in a valid floating-point character.
-  RT_API_ATTRS bool ParseNumber(const char *&, bool &inexact, const char *end);
-
-  using Raw = typename Real::RawType;
-  constexpr RT_API_ATTRS Raw SignBit() const {
-    return Raw{isNegative_} << (Real::bits - 1);
-  }
-  constexpr RT_API_ATTRS Raw Infinity() const {
-    Raw result{static_cast<Raw>(Real::maxExponent)};
-    result <<= Real::significandBits;
-    result |= SignBit();
-    if constexpr (Real::bits == 80) { // x87
-      result |= Raw{1} << 63;
-    }
-    return result;
-  }
-  constexpr RT_API_ATTRS Raw NaN(bool isQuiet = true) {
-    Raw result{Real::maxExponent};
-    result <<= Real::significandBits;
-    result |= SignBit();
-    if constexpr (Real::bits == 80) { // x87
-      result |= Raw{isQuiet ? 3u : 2u} << 62;
-    } else {
-      Raw quiet{isQuiet ? Raw{2} : Raw{1}};
-      quiet <<= Real::significandBits - 2;
-      result |= quiet;
-    }
-    return result;
-  }
-  constexpr RT_API_ATTRS Raw HUGE() const {
-    Raw result{static_cast<Raw>(Real::maxExponent)};
-    result <<= Real::significandBits;
-    result |= SignBit();
-    return result - 1; // decrement exponent, set all significand bits
-  }
-
-  Digit digit_[maxDigits]; // in little-endian order: digit_[0] is LSD
-  int digits_{0}; // # of elements in digit_[] array; zero when zero
-  int digitLimit_{maxDigits}; // precision clamp
-  int exponent_{0}; // signed power of ten
-  bool isNegative_{false};
-  enum FortranRounding rounding_ { RoundNearest };
-};
-} // namespace Fortran::decimal
-#endif
diff --git a/flang/test/CMakeLists.txt b/flang/test/CMakeLists.txt
index 60261ea352780a..03fa79979470ee 100644
--- a/flang/test/CMakeLists.txt
+++ b/flang/test/CMakeLists.txt
@@ -63,7 +63,6 @@ set(FLANG_TEST_DEPENDS
   FileCheck
   count
   not
-#  module_files
   fir-opt
   tco
   bbc
diff --git a/flang/tools/bbc/bbc.cpp b/flang/tools/bbc/bbc.cpp
index e9ec6b7116e0aa..917e052ef35fa1 100644
--- a/flang/tools/bbc/bbc.cpp
+++ b/flang/tools/bbc/bbc.cpp
@@ -14,10 +14,6 @@
 ///
 //===----------------------------------------------------------------------===//
 
-#include "flang/Support/Fortran-features.h"
-#include "flang/Support/OpenMP-features.h"
-#include "flang/Support/Version.h"
-#include "flang/Support/default-kinds.h"
 #include "flang/Frontend/TargetOptions.h"
 #include "flang/Lower/Bridge.h"
 #include "flang/Lower/PFTBuilder.h"
@@ -40,6 +36,10 @@
 #include "flang/Semantics/runtime-type-info.h"
 #include "flang/Semantics/semantics.h"
 #include "flang/Semantics/unparse-with-symbols.h"
+#include "flang/Support/Fortran-features.h"
+#include "flang/Support/OpenMP-features.h"
+#include "flang/Support/Version.h"
+#include "flang/Support/default-kinds.h"
 #include "flang/Tools/CrossToolHelpers.h"
 #include "flang/Tools/TargetSetup.h"
 #include "flang/Version.inc"
diff --git a/flang/tools/f18-parse-demo/f18-parse-demo.cpp b/flang/tools/f18-parse-demo/f18-parse-demo.cpp
index 691b6cebec9b51..a50c88dc840643 100644
--- a/flang/tools/f18-parse-demo/f18-parse-demo.cpp
+++ b/flang/tools/f18-parse-demo/f18-parse-demo.cpp
@@ -21,8 +21,6 @@
 // scaffolding compiler driver that can test some semantic passes of the
 // F18 compiler under development.
 
-#include "flang/Support/Fortran-features.h"
-#include "flang/Support/default-kinds.h"
 #include "flang/Parser/characters.h"
 #include "flang/Parser/dump-parse-tree.h"
 #include "flang/Parser/message.h"
@@ -31,6 +29,8 @@
 #include "flang/Parser/parsing.h"
 #include "flang/Parser/provenance.h"
 #include "flang/Parser/unparse.h"
+#include "flang/Support/Fortran-features.h"
+#include "flang/Support/default-kinds.h"
 #include "llvm/Support/Errno.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Program.h"
diff --git a/flang/unittests/Evaluate/expression.cpp b/flang/unittests/Evaluate/expression.cpp
index 6349997bafee48..d575f36def287e 100644
--- a/flang/unittests/Evaluate/expression.cpp
+++ b/flang/unittests/Evaluate/expression.cpp
@@ -1,10 +1,10 @@
 #include "flang/Evaluate/expression.h"
-#include "flang/Testing/testing.h"
 #include "flang/Evaluate/fold.h"
 #include "flang/Evaluate/intrinsics.h"
 #include "flang/Evaluate/target.h"
 #include "flang/Evaluate/tools.h"
 #include "flang/Parser/message.h"
+#include "flang/Testing/testing.h"
 #include <cstdio>
 #include <cstdlib>
 #include <string>
diff --git a/flang/unittests/Evaluate/folding.cpp b/flang/unittests/Evaluate/folding.cpp
index 35df702ff20ea6..832e55d44316da 100644
--- a/flang/unittests/Evaluate/folding.cpp
+++ b/flang/unittests/Evaluate/folding.cpp
@@ -1,4 +1,3 @@
-#include "flang/Testing/testing.h"
 #include "../../lib/Evaluate/host.h"
 #include "flang/Evaluate/call.h"
 #include "flang/Evaluate/expression.h"
@@ -7,6 +6,7 @@
 #include "flang/Evaluate/intrinsics.h"
 #include "flang/Evaluate/target.h"
 #include "flang/Evaluate/tools.h"
+#include "flang/Testing/testing.h"
 #include <tuple>
 
 using namespace Fortran::evaluate;
diff --git a/flang/unittests/Evaluate/intrinsics.cpp b/flang/unittests/Evaluate/intrinsics.cpp
index 0baf01a4cb1b7e..cca2f8c30247e0 100644
--- a/flang/unittests/Evaluate/intrinsics.cpp
+++ b/flang/unittests/Evaluate/intrinsics.cpp
@@ -1,10 +1,10 @@
 #include "flang/Evaluate/intrinsics.h"
-#include "flang/Testing/testing.h"
 #include "flang/Evaluate/common.h"
 #include "flang/Evaluate/expression.h"
 #include "flang/Evaluate/target.h"
 #include "flang/Evaluate/tools.h"
 #include "flang/Parser/provenance.h"
+#include "flang/Testing/testing.h"
 #include "llvm/Support/raw_ostream.h"
 #include <initializer_list>
 #include <map>
diff --git a/flang/unittests/Evaluate/logical.cpp b/flang/unittests/Evaluate/logical.cpp
index ee568371eab86c..ba7d0d8d0c0e3a 100644
--- a/flang/unittests/Evaluate/logical.cpp
+++ b/flang/unittests/Evaluate/logical.cpp
@@ -1,5 +1,5 @@
-#include "flang/Testing/testing.h"
 #include "flang/Evaluate/type.h"
+#include "flang/Testing/testing.h"
 #include <cstdio>
 
 template <int KIND> void testKind() {
diff --git a/flang/unittests/Evaluate/real.cpp b/flang/unittests/Evaluate/real.cpp
index ab1a178df22312..23406fc6909aea 100644
--- a/flang/unittests/Evaluate/real.cpp
+++ b/flang/unittests/Evaluate/real.cpp
@@ -1,6 +1,6 @@
+#include "flang/Evaluate/type.h"
 #include "flang/Testing/fp-testing.h"
 #include "flang/Testing/testing.h"
-#include "flang/Evaluate/type.h"
 #include "llvm/Support/raw_ostream.h"
 #include <cmath>
 #include <cstdio>
diff --git a/lld/COFF/MinGW.cpp b/lld/COFF/MinGW.cpp
index e4e6a3bb52410f..74d1ae0615fa6a 100644
--- a/lld/COFF/MinGW.cpp
+++ b/lld/COFF/MinGW.cpp
@@ -51,7 +51,6 @@ AutoExporter::AutoExporter(
       "libc++",
       "libc++abi",
       "libFortranRuntime",
-      "libFortranFloat128Math",
       "libFortranRuntime.static",
       "libFortranRuntime.dynamic",
       "libFortranRuntime.static_dbg",
diff --git a/llvm/projects/CMakeLists.txt b/llvm/projects/CMakeLists.txt
index fab28c9df6d384..d8808bc79f0129 100644
--- a/llvm/projects/CMakeLists.txt
+++ b/llvm/projects/CMakeLists.txt
@@ -38,7 +38,6 @@ if(${LLVM_BUILD_RUNTIME})
   if(NOT LLVM_BUILD_EXTERNAL_COMPILER_RT)
     add_llvm_external_project(compiler-rt)
   endif()
-
   add_llvm_external_project(FortranRuntime)
 endif()
 
diff --git a/llvm/runtimes/CMakeLists.txt b/llvm/runtimes/CMakeLists.txt
index e4389b120f49df..5da91169058724 100644
--- a/llvm/runtimes/CMakeLists.txt
+++ b/llvm/runtimes/CMakeLists.txt
@@ -510,14 +510,7 @@ if(build_runtimes)
     list(APPEND extra_cmake_args "-DCMAKE_PROGRAM_PATH=${CMAKE_PROGRAM_PATH}")
   endif()
 
-  # FIXME: Go away
   if("openmp" IN_LIST LLVM_ENABLE_RUNTIMES)
-    #if (LLVM_TOOL_FLANG_BUILD AND "FortranRuntime" IN_LIST LLVM_ENABLE_PROJECTS)
-    #  message(STATUS "Configuring build of omp_lib.mod and omp_lib_kinds.mod via flang-new")
-    #  set(LIBOMP_FORTRAN_MODULES_COMPILER "${CMAKE_BINARY_DIR}/bin/flang-new${CMAKE_EXECUTABLE_SUFFIX}")
-    #  #TODO: set(LIBOMP_MODULES_INSTALL_PATH "${CMAKE_INSTALL_INCLUDEDIR}/flang")
-    #  list(APPEND extra_deps "flang-new")
-    #endif()
     if (LLVM_TOOL_FLANG_BUILD AND "FortranRuntime" IN_LIST LLVM_ENABLE_PROJECTS)
       set(enable_fortran ENABLE_FORTRAN)
     endif ()
diff --git a/runtimes/CMakeLists.txt b/runtimes/CMakeLists.txt
index d77b4da6e00e34..2a7798fd60af42 100644
--- a/runtimes/CMakeLists.txt
+++ b/runtimes/CMakeLists.txt
@@ -49,7 +49,6 @@ function(runtime_register_component name)
   set_property(GLOBAL APPEND PROPERTY SUB_COMPONENTS ${name})
 endfunction()
 
-message("LLVM_BINARY_DIR: ${LLVM_BINARY_DIR}")
 find_package(LLVM PATHS "${LLVM_BINARY_DIR}" NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH)
 find_package(Clang PATHS "${LLVM_BINARY_DIR}" NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH)
 



More information about the flang-commits mailing list