[llvm-branch-commits] [flang] [Flang] Introduce FortranSupport (PR #122069)

Michael Kruse via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Thu Jan 23 07:02:18 PST 2025


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

>From 69f7bd62381a63cffbcde365a27b76b0f279a86f Mon Sep 17 00:00:00 2001
From: Michael Kruse <llvm-project at meinersbur.de>
Date: Wed, 8 Jan 2025 09:32:19 +0100
Subject: [PATCH 1/9] Introduce FortranSupport

---
 .../ISO_Fortran_binding_wrapper.h             | 15 +++--
 flang/include/flang/Common/fast-int-set.h     |  6 +-
 flang/include/flang/Evaluate/call.h           |  6 +-
 .../include/flang/Evaluate/characteristics.h  |  6 +-
 flang/include/flang/Evaluate/common.h         |  8 +--
 flang/include/flang/Evaluate/constant.h       |  4 +-
 flang/include/flang/Evaluate/expression.h     |  6 +-
 flang/include/flang/Evaluate/formatting.h     |  2 +-
 flang/include/flang/Evaluate/intrinsics.h     |  2 +-
 flang/include/flang/Evaluate/shape.h          |  2 +-
 flang/include/flang/Evaluate/target.h         |  2 +-
 flang/include/flang/Evaluate/tools.h          |  4 +-
 flang/include/flang/Evaluate/traverse.h       |  2 +-
 flang/include/flang/Evaluate/type.h           |  6 +-
 flang/include/flang/Evaluate/variable.h       |  4 +-
 .../flang/Frontend/CompilerInvocation.h       |  2 +-
 .../include/flang/Frontend/FrontendOptions.h  |  2 +-
 flang/include/flang/ISO_Fortran_binding.h     |  2 +-
 flang/include/flang/Lower/AbstractConverter.h |  2 +-
 flang/include/flang/Lower/Bridge.h            |  2 +-
 flang/include/flang/Lower/CallInterface.h     |  2 +-
 flang/include/flang/Lower/ConvertType.h       |  2 +-
 flang/include/flang/Lower/LoweringOptions.h   |  2 +-
 flang/include/flang/Lower/PFTBuilder.h        |  4 +-
 flang/include/flang/Lower/Support/Utils.h     |  2 +-
 flang/include/flang/Lower/SymbolMap.h         |  2 +-
 .../flang/Optimizer/Builder/FIRBuilder.h      |  2 +-
 .../Optimizer/Builder/PPCIntrinsicCall.h      |  2 +-
 .../Optimizer/Builder/Runtime/RTBuilder.h     |  2 +-
 .../flang/Optimizer/CodeGen/DescriptorModel.h |  2 +-
 .../Dialect/CUF/Attributes/CUFAttr.h          |  2 +-
 .../flang/Optimizer/Support/TypeCode.h        |  2 +-
 flang/include/flang/Optimizer/Support/Utils.h |  2 +-
 flang/include/flang/Parser/char-block.h       |  2 +-
 flang/include/flang/Parser/dump-parse-tree.h  |  4 +-
 flang/include/flang/Parser/message.h          |  4 +-
 flang/include/flang/Parser/parse-state.h      |  2 +-
 flang/include/flang/Parser/parse-tree.h       |  4 +-
 flang/include/flang/Parser/parsing.h          |  2 +-
 flang/include/flang/Parser/provenance.h       |  2 +-
 flang/include/flang/Parser/source.h           |  2 +-
 flang/include/flang/Parser/user-state.h       |  2 +-
 flang/include/flang/Runtime/allocatable.h     |  5 +-
 .../include/flang/Runtime/descriptor-consts.h |  2 +-
 flang/include/flang/Runtime/descriptor.h      |  2 +-
 flang/include/flang/Runtime/io-api.h          |  2 +-
 flang/include/flang/Runtime/pointer.h         |  8 ++-
 flang/include/flang/Runtime/random.h          |  5 ++
 flang/include/flang/Runtime/support.h         |  2 +-
 flang/include/flang/Runtime/type-code.h       |  2 +-
 flang/include/flang/Semantics/expression.h    |  4 +-
 .../flang/Semantics/runtime-type-info.h       |  2 +-
 flang/include/flang/Semantics/scope.h         |  4 +-
 flang/include/flang/Semantics/semantics.h     |  5 +-
 flang/include/flang/Semantics/symbol.h        |  4 +-
 flang/include/flang/Semantics/tools.h         |  2 +-
 flang/include/flang/Semantics/type.h          |  2 +-
 .../{Common => Support}/Fortran-features.h    | 10 +--
 .../flang/{Common => Support}/Fortran.h       | 12 ++--
 .../flang/{Common => Support}/LangOptions.def |  0
 .../flang/{Common => Support}/LangOptions.h   | 14 ++---
 .../{Common => Support}/MathOptionsBase.def   |  0
 .../{Common => Support}/MathOptionsBase.h     | 14 ++---
 .../{Common => Support}/OpenMP-features.h     |  8 +--
 .../flang/{Common => Support}/Version.h       |  8 +--
 .../flang/{Common => Support}/default-kinds.h | 10 +--
 .../flang/{Common => Support}/indirection.h   | 10 +--
 .../flang/{Common => Support}/interval.h      | 10 +--
 .../{Common => Support}/reference-counted.h   |  8 +--
 .../flang/{Common => Support}/reference.h     |  8 +--
 .../static-multimap-view.h                    |  8 +--
 .../flang/{Common => Support}/template.h      | 10 +--
 .../flang/{Common => Support}/unwrap.h        | 12 ++--
 flang/include/flang/Tools/CrossToolHelpers.h  |  4 +-
 flang/lib/CMakeLists.txt                      |  1 +
 flang/lib/Common/CMakeLists.txt               | 56 +++--------------
 flang/lib/Evaluate/CMakeLists.txt             |  1 +
 flang/lib/Evaluate/call.cpp                   |  2 +-
 flang/lib/Evaluate/characteristics.cpp        |  2 +-
 flang/lib/Evaluate/fold-implementation.h      |  6 +-
 flang/lib/Evaluate/formatting.cpp             |  2 +-
 flang/lib/Evaluate/intrinsics-library.cpp     |  2 +-
 flang/lib/Evaluate/intrinsics.cpp             |  2 +-
 flang/lib/Evaluate/real.cpp                   |  2 +-
 flang/lib/Evaluate/shape.cpp                  |  2 +-
 flang/lib/Evaluate/target.cpp                 |  2 +-
 flang/lib/Frontend/CMakeLists.txt             |  1 +
 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                |  1 +
 flang/lib/Lower/CallInterface.cpp             |  2 +-
 flang/lib/Lower/ConvertExpr.cpp               |  4 +-
 flang/lib/Lower/Mangler.cpp                   |  2 +-
 flang/lib/Optimizer/Builder/IntrinsicCall.cpp |  4 +-
 flang/lib/Optimizer/CodeGen/TypeConverter.cpp |  2 +-
 flang/lib/Optimizer/Dialect/FIRType.cpp       |  4 +-
 flang/lib/Optimizer/OpenMP/CMakeLists.txt     |  1 +
 flang/lib/Optimizer/Passes/CMakeLists.txt     |  4 +-
 .../lib/Optimizer/Transforms/AddDebugInfo.cpp |  2 +-
 .../Transforms/AssumedRankOpConversion.cpp    |  2 +-
 flang/lib/Optimizer/Transforms/CMakeLists.txt |  1 +
 .../Optimizer/Transforms/CUFDeviceGlobal.cpp  |  2 +-
 .../Transforms/CUFGPUToLLVMConversion.cpp     |  2 +-
 .../Optimizer/Transforms/CUFOpConversion.cpp  |  2 +-
 .../Transforms/ExternalNameConversion.cpp     |  2 +-
 .../Optimizer/Transforms/LoopVersioning.cpp   |  2 +-
 .../Transforms/SimplifyIntrinsics.cpp         |  2 +-
 .../lib/Optimizer/Transforms/StackReclaim.cpp |  2 +-
 flang/lib/Optimizer/Transforms/VScaleAttr.cpp |  2 +-
 flang/lib/Parser/CMakeLists.txt               |  1 +
 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            |  1 +
 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              | 61 +++++++++++++++++++
 .../{Common => Support}/Fortran-features.cpp  |  6 +-
 flang/lib/{Common => Support}/Fortran.cpp     |  6 +-
 flang/lib/{Common => Support}/LangOptions.cpp |  6 +-
 .../lib/{Common => Support}/OpenMP-utils.cpp  |  2 +-
 flang/lib/{Common => Support}/Version.cpp     |  4 +-
 .../lib/{Common => Support}/default-kinds.cpp |  4 +-
 flang/lib/{Common => Support}/idioms.cpp      |  2 +-
 flang/runtime/CUDA/allocator.cpp              |  2 +-
 flang/runtime/ISO_Fortran_binding.cpp         |  2 +-
 flang/runtime/ISO_Fortran_util.h              |  2 +-
 flang/runtime/allocatable.cpp                 |  2 +-
 flang/runtime/edit-output.h                   |  2 +-
 flang/runtime/environment.h                   |  2 +-
 flang/runtime/format-implementation.h         |  2 +-
 flang/runtime/format.h                        |  2 +-
 flang/runtime/stat.h                          |  2 +-
 flang/runtime/temporary-stack.cpp             |  2 +-
 flang/tools/bbc/CMakeLists.txt                |  1 +
 flang/tools/bbc/bbc.cpp                       | 10 +--
 flang/tools/f18-parse-demo/f18-parse-demo.cpp |  4 +-
 .../Evaluate/ISO-Fortran-binding.cpp          |  2 +-
 flang/unittests/Runtime/TemporaryStack.cpp    |  2 +-
 159 files changed, 353 insertions(+), 315 deletions(-)
 rename flang/include/flang/{ => Common}/ISO_Fortran_binding_wrapper.h (70%)
 rename flang/include/flang/{Common => Support}/Fortran-features.h (96%)
 rename flang/include/flang/{Common => Support}/Fortran.h (94%)
 rename flang/include/flang/{Common => Support}/LangOptions.def (100%)
 rename flang/include/flang/{Common => Support}/LangOptions.h (87%)
 rename flang/include/flang/{Common => Support}/MathOptionsBase.def (100%)
 rename flang/include/flang/{Common => Support}/MathOptionsBase.h (77%)
 rename flang/include/flang/{Common => Support}/OpenMP-features.h (85%)
 rename flang/include/flang/{Common => Support}/Version.h (90%)
 rename flang/include/flang/{Common => Support}/default-kinds.h (91%)
 rename flang/include/flang/{Common => Support}/indirection.h (95%)
 rename flang/include/flang/{Common => Support}/interval.h (94%)
 rename flang/include/flang/{Common => Support}/reference-counted.h (90%)
 rename flang/include/flang/{Common => Support}/reference.h (91%)
 rename flang/include/flang/{Common => Support}/static-multimap-view.h (91%)
 rename flang/include/flang/{Common => Support}/template.h (98%)
 rename flang/include/flang/{Common => Support}/unwrap.h (94%)
 create mode 100644 flang/lib/Support/CMakeLists.txt
 rename flang/lib/{Common => Support}/Fortran-features.cpp (97%)
 rename flang/lib/{Common => Support}/Fortran.cpp (96%)
 rename flang/lib/{Common => Support}/LangOptions.cpp (80%)
 rename flang/lib/{Common => Support}/OpenMP-utils.cpp (95%)
 rename flang/lib/{Common => Support}/Version.cpp (95%)
 rename flang/lib/{Common => Support}/default-kinds.cpp (94%)
 rename flang/lib/{Common => Support}/idioms.cpp (89%)

diff --git a/flang/include/flang/ISO_Fortran_binding_wrapper.h b/flang/include/flang/Common/ISO_Fortran_binding_wrapper.h
similarity index 70%
rename from flang/include/flang/ISO_Fortran_binding_wrapper.h
rename to flang/include/flang/Common/ISO_Fortran_binding_wrapper.h
index 37289bdbabd03c..7a8a8a9787bd03 100644
--- a/flang/include/flang/ISO_Fortran_binding_wrapper.h
+++ b/flang/include/flang/Common/ISO_Fortran_binding_wrapper.h
@@ -1,14 +1,13 @@
-/*===-- include/flang/ISO_Fortran_binding_wrapper.h ---------------*- C++ -*-===
+/*===-- include/flang/Common/ISO_Fortran_binding_wrapper.h ----------*- C -*-===
  *
  * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  * See https://llvm.org/LICENSE.txt for license information.
  * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  *
- * ===-----------------------------------------------------------------------===
- */
+ *===----------------------------------------------------------------------===*/
 
-#ifndef FORTRAN_ISO_FORTRAN_BINDING_WRAPPER_H_
-#define FORTRAN_ISO_FORTRAN_BINDING_WRAPPER_H_
+#ifndef FORTRAN_COMMON_ISO_FORTRAN_BINDING_WRAPPER_H_
+#define FORTRAN_COMMON_ISO_FORTRAN_BINDING_WRAPPER_H_
 
 /* A thin wrapper around flang/include/ISO_Fortran_binding.h
  * This header file must be included when ISO_Fortran_binding.h
@@ -23,17 +22,17 @@
 
 /* clang-format off */
 #include <stddef.h>
-#include "Common/api-attrs.h"
+#include "flang/Common/api-attrs.h"
 #ifdef __cplusplus
 namespace Fortran {
 namespace ISO {
 #define FORTRAN_ISO_NAMESPACE_ ::Fortran::ISO
 #endif /* __cplusplus */
-#include "ISO_Fortran_binding.h"
+#include "flang/ISO_Fortran_binding.h"
 #ifdef __cplusplus
 } // namespace ISO
 } // namespace Fortran
 #endif /* __cplusplus */
 /* clang-format on */
 
-#endif /* FORTRAN_ISO_FORTRAN_BINDING_WRAPPER_H_ */
+#endif /* FORTRAN_COMMON_ISO_FORTRAN_BINDING_WRAPPER_H_ */
diff --git a/flang/include/flang/Common/fast-int-set.h b/flang/include/flang/Common/fast-int-set.h
index d1c9c756a44a65..1214bac75a4bf1 100644
--- a/flang/include/flang/Common/fast-int-set.h
+++ b/flang/include/flang/Common/fast-int-set.h
@@ -24,7 +24,7 @@
 #ifndef FORTRAN_COMMON_FAST_INT_SET_H_
 #define FORTRAN_COMMON_FAST_INT_SET_H_
 
-#include <optional>
+#include "optional.h"
 
 namespace Fortran::common {
 
@@ -83,9 +83,9 @@ template <int N> class FastIntSet {
     }
   }
 
-  std::optional<int> PopValue() {
+  optional<int> PopValue() {
     if (IsEmpty()) {
-      return std::nullopt;
+      return nullopt;
     } else {
       return value_[--size_];
     }
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 9ea037a2f7c429..2798f77b898746 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 154561ce868eb1..c8b96619287b13 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 f586c59d46e54c..c309314a719330 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 90b93f6afd3515..e40b839aa6e1e9 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 1f9296ac4fea75..ab7e4723152d7e 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/CompilerInvocation.h b/flang/include/flang/Frontend/CompilerInvocation.h
index 50d908d0832024..60a43c67e84800 100644
--- a/flang/include/flang/Frontend/CompilerInvocation.h
+++ b/flang/include/flang/Frontend/CompilerInvocation.h
@@ -13,7 +13,6 @@
 #ifndef FORTRAN_FRONTEND_COMPILERINVOCATION_H
 #define FORTRAN_FRONTEND_COMPILERINVOCATION_H
 
-#include "flang/Common/LangOptions.h"
 #include "flang/Frontend/CodeGenOptions.h"
 #include "flang/Frontend/FrontendOptions.h"
 #include "flang/Frontend/PreprocessorOptions.h"
@@ -21,6 +20,7 @@
 #include "flang/Lower/LoweringOptions.h"
 #include "flang/Parser/parsing.h"
 #include "flang/Semantics/semantics.h"
+#include "flang/Support/LangOptions.h"
 #include "clang/Basic/Diagnostic.h"
 #include "clang/Basic/DiagnosticOptions.h"
 #include "llvm/Option/ArgList.h"
diff --git a/flang/include/flang/Frontend/FrontendOptions.h b/flang/include/flang/Frontend/FrontendOptions.h
index a4cb021e309d4a..0bd2e621813ca5 100644
--- a/flang/include/flang/Frontend/FrontendOptions.h
+++ b/flang/include/flang/Frontend/FrontendOptions.h
@@ -13,10 +13,10 @@
 #ifndef FORTRAN_FRONTEND_FRONTENDOPTIONS_H
 #define FORTRAN_FRONTEND_FRONTENDOPTIONS_H
 
-#include "flang/Common/Fortran-features.h"
 #include "flang/Lower/EnvironmentDefault.h"
 #include "flang/Parser/characters.h"
 #include "flang/Parser/unparse.h"
+#include "flang/Support/Fortran-features.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include <cstdint>
diff --git a/flang/include/flang/ISO_Fortran_binding.h b/flang/include/flang/ISO_Fortran_binding.h
index 945f8fef89f0b4..f5b8d0d2ea610a 100644
--- a/flang/include/flang/ISO_Fortran_binding.h
+++ b/flang/include/flang/ISO_Fortran_binding.h
@@ -14,7 +14,7 @@
  * it does so by means of a wrapper header that establishes namespaces and
  * a macro for extra function attributes (RT_API_ATTRS).
  */
-#ifndef FORTRAN_ISO_FORTRAN_BINDING_WRAPPER_H_
+#ifndef FORTRAN_COMMON_ISO_FORTRAN_BINDING_WRAPPER_H_
 #include <stddef.h>
 #define FORTRAN_ISO_NAMESPACE_
 #endif
diff --git a/flang/include/flang/Lower/AbstractConverter.h b/flang/include/flang/Lower/AbstractConverter.h
index 607aff41f64595..4a21b571ce106b 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 6404a16f7785ae..a8c2bcfda31c1f 100644
--- a/flang/include/flang/Lower/Bridge.h
+++ b/flang/include/flang/Lower/Bridge.h
@@ -13,7 +13,6 @@
 #ifndef FORTRAN_LOWER_BRIDGE_H
 #define FORTRAN_LOWER_BRIDGE_H
 
-#include "flang/Common/Fortran.h"
 #include "flang/Frontend/CodeGenOptions.h"
 #include "flang/Frontend/TargetOptions.h"
 #include "flang/Lower/AbstractConverter.h"
@@ -22,6 +21,7 @@
 #include "flang/Lower/StatementContext.h"
 #include "flang/Optimizer/Builder/FIRBuilder.h"
 #include "flang/Optimizer/Dialect/Support/KindMapping.h"
+#include "flang/Support/Fortran.h"
 #include "mlir/IR/BuiltinOps.h"
 #include "mlir/IR/OwningOpRef.h"
 #include <set>
diff --git a/flang/include/flang/Lower/CallInterface.h b/flang/include/flang/Lower/CallInterface.h
index 72bc9dd890a94b..c15edf62df388e 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 42d6546b77553b..05da17faf2dd7d 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 6ee4370c99dca5..0aa2354e8bb0b1 100644
--- a/flang/include/flang/Optimizer/Builder/FIRBuilder.h
+++ b/flang/include/flang/Optimizer/Builder/FIRBuilder.h
@@ -16,12 +16,12 @@
 #ifndef FORTRAN_OPTIMIZER_BUILDER_FIRBUILDER_H
 #define FORTRAN_OPTIMIZER_BUILDER_FIRBUILDER_H
 
-#include "flang/Common/MathOptionsBase.h"
 #include "flang/Optimizer/Dialect/FIROps.h"
 #include "flang/Optimizer/Dialect/FIROpsSupport.h"
 #include "flang/Optimizer/Dialect/FIRType.h"
 #include "flang/Optimizer/Dialect/Support/FIRContext.h"
 #include "flang/Optimizer/Dialect/Support/KindMapping.h"
+#include "flang/Support/MathOptionsBase.h"
 #include "mlir/IR/Builders.h"
 #include "mlir/IR/BuiltinOps.h"
 #include "llvm/ADT/DenseMap.h"
diff --git a/flang/include/flang/Optimizer/Builder/PPCIntrinsicCall.h b/flang/include/flang/Optimizer/Builder/PPCIntrinsicCall.h
index 5ae32f70a11a7f..8374b18b8a17d8 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 09b49b95fefe57..8d19df8f97e9bd 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 9cccf8db87270e..b9a8a670d07938 100644
--- a/flang/include/flang/Optimizer/CodeGen/DescriptorModel.h
+++ b/flang/include/flang/Optimizer/CodeGen/DescriptorModel.h
@@ -22,7 +22,7 @@
 #ifndef OPTIMIZER_DESCRIPTOR_MODEL_H
 #define OPTIMIZER_DESCRIPTOR_MODEL_H
 
-#include "flang/ISO_Fortran_binding_wrapper.h"
+#include "flang/Common/ISO_Fortran_binding_wrapper.h"
 #include "flang/Runtime/descriptor-consts.h"
 #include "mlir/Dialect/LLVMIR/LLVMTypes.h"
 #include "mlir/IR/BuiltinTypes.h"
diff --git a/flang/include/flang/Optimizer/Dialect/CUF/Attributes/CUFAttr.h b/flang/include/flang/Optimizer/Dialect/CUF/Attributes/CUFAttr.h
index 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 d507f4116efb70..ec73af6ec72e90 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 3331520922bc63..7e0333a0923929 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 bc38f571ca3df4..bfbc985b8b91aa 100644
--- a/flang/include/flang/Parser/message.h
+++ b/flang/include/flang/Parser/message.h
@@ -15,10 +15,10 @@
 #include "char-block.h"
 #include "char-set.h"
 #include "provenance.h"
-#include "flang/Common/Fortran-features.h"
 #include "flang/Common/idioms.h"
-#include "flang/Common/reference-counted.h"
 #include "flang/Common/restorer.h"
+#include "flang/Support/Fortran-features.h"
+#include "flang/Support/reference-counted.h"
 #include <cstddef>
 #include <cstring>
 #include <forward_list>
diff --git a/flang/include/flang/Parser/parse-state.h b/flang/include/flang/Parser/parse-state.h
index 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 941d70d3876291..2ae1bb4e7b800a 100644
--- a/flang/include/flang/Parser/parse-tree.h
+++ b/flang/include/flang/Parser/parse-tree.h
@@ -22,9 +22,9 @@
 #include "format-specification.h"
 #include "message.h"
 #include "provenance.h"
-#include "flang/Common/Fortran.h"
 #include "flang/Common/idioms.h"
-#include "flang/Common/indirection.h"
+#include "flang/Support/Fortran.h"
+#include "flang/Support/indirection.h"
 #include "llvm/Frontend/OpenACC/ACC.h.inc"
 #include "llvm/Frontend/OpenMP/OMP.h"
 #include "llvm/Frontend/OpenMP/OMPConstants.h"
diff --git a/flang/include/flang/Parser/parsing.h b/flang/include/flang/Parser/parsing.h
index 0c774decb16d31..116b6bd6f191f5 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/Runtime/allocatable.h b/flang/include/flang/Runtime/allocatable.h
index 58061d9862095e..480e987ed5ec6b 100644
--- a/flang/include/flang/Runtime/allocatable.h
+++ b/flang/include/flang/Runtime/allocatable.h
@@ -11,10 +11,13 @@
 #ifndef FORTRAN_RUNTIME_ALLOCATABLE_H_
 #define FORTRAN_RUNTIME_ALLOCATABLE_H_
 
-#include "flang/Runtime/descriptor.h"
+#include "flang/Common/Fortran-consts.h"
+#include "flang/Runtime/descriptor-consts.h"
 #include "flang/Runtime/entry-names.h"
 
 namespace Fortran::runtime {
+using SubscriptValue = ISO::CFI_index_t;
+using common::TypeCategory;
 
 extern "C" {
 
diff --git a/flang/include/flang/Runtime/descriptor-consts.h b/flang/include/flang/Runtime/descriptor-consts.h
index 3b2537579d5864..abcdbc4a12002c 100644
--- a/flang/include/flang/Runtime/descriptor-consts.h
+++ b/flang/include/flang/Runtime/descriptor-consts.h
@@ -9,8 +9,8 @@
 #ifndef FORTRAN_RUNTIME_DESCRIPTOR_CONSTS_H_
 #define FORTRAN_RUNTIME_DESCRIPTOR_CONSTS_H_
 
+#include "flang/Common/ISO_Fortran_binding_wrapper.h"
 #include "flang/Common/api-attrs.h"
-#include "flang/ISO_Fortran_binding_wrapper.h"
 #include <cstddef>
 #include <cstdint>
 
diff --git a/flang/include/flang/Runtime/descriptor.h b/flang/include/flang/Runtime/descriptor.h
index dd36fba157ca92..628ac8c927a51e 100644
--- a/flang/include/flang/Runtime/descriptor.h
+++ b/flang/include/flang/Runtime/descriptor.h
@@ -18,7 +18,7 @@
 // User C code is welcome to depend on that ISO_Fortran_binding.h file,
 // but should never reference this internal header.
 
-#include "flang/ISO_Fortran_binding_wrapper.h"
+#include "flang/Common/ISO_Fortran_binding_wrapper.h"
 #include "flang/Runtime/descriptor-consts.h"
 #include "flang/Runtime/memory.h"
 #include "flang/Runtime/type-code.h"
diff --git a/flang/include/flang/Runtime/io-api.h b/flang/include/flang/Runtime/io-api.h
index b86c3cecb32c5a..cee6b2cf033094 100644
--- a/flang/include/flang/Runtime/io-api.h
+++ b/flang/include/flang/Runtime/io-api.h
@@ -1,4 +1,4 @@
-//===-- include/flang/Runtime/io-api.h --------------------------*- C++ -*-===//
+//===-- include/flang-rt/io-api.h -------------------------------*- C++ -*-===//
 //
 // Part of the 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/pointer.h b/flang/include/flang/Runtime/pointer.h
index 704144f08114f2..c6d29db7218376 100644
--- a/flang/include/flang/Runtime/pointer.h
+++ b/flang/include/flang/Runtime/pointer.h
@@ -12,10 +12,14 @@
 #ifndef FORTRAN_RUNTIME_POINTER_H_
 #define FORTRAN_RUNTIME_POINTER_H_
 
-#include "flang/Runtime/descriptor.h"
+#include "flang/Common/Fortran-consts.h"
+#include "flang/Runtime/descriptor-consts.h"
 #include "flang/Runtime/entry-names.h"
 
 namespace Fortran::runtime {
+using SubscriptValue = ISO::CFI_index_t;
+using common::TypeCategory;
+
 extern "C" {
 
 // Data pointer initialization for NULLIFY(), "p=>NULL()`, & for ALLOCATE().
@@ -122,4 +126,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/random.h b/flang/include/flang/Runtime/random.h
index 269297dff47dba..bb6dcb3873f21d 100644
--- a/flang/include/flang/Runtime/random.h
+++ b/flang/include/flang/Runtime/random.h
@@ -8,6 +8,9 @@
 
 // Intrinsic subroutines RANDOM_INIT, RANDOM_NUMBER, and RANDOM_SEED.
 
+#ifndef FORTRAN_RUNTIME_RANDOM_H_
+#define FORTRAN_RUNTIME_RANDOM_H_
+
 #include "flang/Runtime/entry-names.h"
 #include <cstdint>
 
@@ -35,3 +38,5 @@ void RTNAME(RandomSeed)(const Descriptor *size, const Descriptor *put,
 
 } // extern "C"
 } // namespace Fortran::runtime
+
+#endif /* FORTRAN_RUNTIME_RANDOM_H_ */
diff --git a/flang/include/flang/Runtime/support.h b/flang/include/flang/Runtime/support.h
index ba9c2598bb0ddd..4a6d4357e87103 100644
--- a/flang/include/flang/Runtime/support.h
+++ b/flang/include/flang/Runtime/support.h
@@ -10,7 +10,7 @@
 #ifndef FORTRAN_RUNTIME_SUPPORT_H_
 #define FORTRAN_RUNTIME_SUPPORT_H_
 
-#include "flang/ISO_Fortran_binding_wrapper.h"
+#include "flang/Common/ISO_Fortran_binding_wrapper.h"
 #include "flang/Runtime/entry-names.h"
 #include <cstddef>
 #include <cstdint>
diff --git a/flang/include/flang/Runtime/type-code.h b/flang/include/flang/Runtime/type-code.h
index dd3a9f2690ee74..ae854ed2145e46 100644
--- a/flang/include/flang/Runtime/type-code.h
+++ b/flang/include/flang/Runtime/type-code.h
@@ -10,8 +10,8 @@
 #define FORTRAN_RUNTIME_TYPE_CODE_H_
 
 #include "flang/Common/Fortran-consts.h"
+#include "flang/Common/ISO_Fortran_binding_wrapper.h"
 #include "flang/Common/optional.h"
-#include "flang/ISO_Fortran_binding_wrapper.h"
 #include <utility>
 
 namespace Fortran::runtime {
diff --git a/flang/include/flang/Semantics/expression.h b/flang/include/flang/Semantics/expression.h
index bb1674a9f88778..8ea33902bd2137 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 b3b033a5a3ae3c..b7d115ec2bca4e 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 c981d86fbd94cb..65ec1ce1eb6e33 100644
--- a/flang/include/flang/Semantics/semantics.h
+++ b/flang/include/flang/Semantics/semantics.h
@@ -13,12 +13,13 @@
 #include "program-tree.h"
 #include "scope.h"
 #include "symbol.h"
-#include "flang/Common/Fortran-features.h"
-#include "flang/Common/LangOptions.h"
 #include "flang/Evaluate/common.h"
 #include "flang/Evaluate/intrinsics.h"
 #include "flang/Evaluate/target.h"
 #include "flang/Parser/message.h"
+#include "flang/Semantics/module-dependences.h"
+#include "flang/Support/Fortran-features.h"
+#include "flang/Support/LangOptions.h"
 #include <iosfwd>
 #include <set>
 #include <string>
diff --git a/flang/include/flang/Semantics/symbol.h b/flang/include/flang/Semantics/symbol.h
index 2f97efddf7f7ba..1cd48041a04a2b 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 96d4dbb2acaa11..a21f603ce66dd3 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 35221915020595..5d96f1e89bf52c 100644
--- a/flang/include/flang/Semantics/type.h
+++ b/flang/include/flang/Semantics/type.h
@@ -9,10 +9,10 @@
 #ifndef FORTRAN_SEMANTICS_TYPE_H_
 #define FORTRAN_SEMANTICS_TYPE_H_
 
-#include "flang/Common/Fortran.h"
 #include "flang/Common/idioms.h"
 #include "flang/Evaluate/expression.h"
 #include "flang/Parser/char-block.h"
+#include "flang/Support/Fortran.h"
 #include <algorithm>
 #include <iosfwd>
 #include <map>
diff --git a/flang/include/flang/Common/Fortran-features.h b/flang/include/flang/Support/Fortran-features.h
similarity index 96%
rename from flang/include/flang/Common/Fortran-features.h
rename to flang/include/flang/Support/Fortran-features.h
index 44f88009f8f2c2..690329411dc50d 100644
--- a/flang/include/flang/Common/Fortran-features.h
+++ b/flang/include/flang/Support/Fortran-features.h
@@ -1,4 +1,4 @@
-//===-- include/flang/Common/Fortran-features.h -----------------*- C++ -*-===//
+//===-- include/flang/Support/Fortran-features.h ----------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -6,12 +6,12 @@
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef FORTRAN_COMMON_FORTRAN_FEATURES_H_
-#define FORTRAN_COMMON_FORTRAN_FEATURES_H_
+#ifndef FORTRAN_SUPPORT_FORTRAN_FEATURES_H_
+#define FORTRAN_SUPPORT_FORTRAN_FEATURES_H_
 
-#include "flang/Common/Fortran.h"
 #include "flang/Common/enum-set.h"
 #include "flang/Common/idioms.h"
+#include "flang/Support/Fortran.h"
 #include <optional>
 #include <vector>
 
@@ -125,4 +125,4 @@ class LanguageFeatureControl {
   bool warnAllUsage_{false};
 };
 } // namespace Fortran::common
-#endif // FORTRAN_COMMON_FORTRAN_FEATURES_H_
+#endif /* FORTRAN_SUPPORT_FORTRAN_FEATURES_H_ */
diff --git a/flang/include/flang/Common/Fortran.h b/flang/include/flang/Support/Fortran.h
similarity index 94%
rename from flang/include/flang/Common/Fortran.h
rename to flang/include/flang/Support/Fortran.h
index e1922f7654bb1a..4e6bdbb67f5f35 100644
--- a/flang/include/flang/Common/Fortran.h
+++ b/flang/include/flang/Support/Fortran.h
@@ -1,4 +1,4 @@
-//===-- include/flang/Common/Fortran.h --------------------------*- C++ -*-===//
+//===-- include/flang/Support/Fortran.h -------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -6,15 +6,15 @@
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef FORTRAN_COMMON_FORTRAN_H_
-#define FORTRAN_COMMON_FORTRAN_H_
+#ifndef FORTRAN_SUPPORT_FORTRAN_H_
+#define FORTRAN_SUPPORT_FORTRAN_H_
 
 // Fortran language concepts that are used in many phases are defined
 // once here to avoid redundancy and needless translation.
 
-#include "enum-set.h"
-#include "idioms.h"
 #include "flang/Common/Fortran-consts.h"
+#include "flang/Common/enum-set.h"
+#include "flang/Common/idioms.h"
 #include <cinttypes>
 #include <optional>
 #include <string>
@@ -109,4 +109,4 @@ inline std::string GetExternalAssemblyName(
 }
 
 } // namespace Fortran::common
-#endif // FORTRAN_COMMON_FORTRAN_H_
+#endif /* FORTRAN_SUPPORT_FORTRAN_H_ */
diff --git a/flang/include/flang/Common/LangOptions.def b/flang/include/flang/Support/LangOptions.def
similarity index 100%
rename from flang/include/flang/Common/LangOptions.def
rename to flang/include/flang/Support/LangOptions.def
diff --git a/flang/include/flang/Common/LangOptions.h b/flang/include/flang/Support/LangOptions.h
similarity index 87%
rename from flang/include/flang/Common/LangOptions.h
rename to flang/include/flang/Support/LangOptions.h
index 83f25cfbe26142..3c6094c9a9c87f 100644
--- a/flang/include/flang/Common/LangOptions.h
+++ b/flang/include/flang/Support/LangOptions.h
@@ -1,4 +1,4 @@
-//===------ LangOptions.h ---------------------------------------*- C++ -*-===//
+//===-- include/flang/Support/LangOptions.h ---------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -12,8 +12,8 @@
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef FORTRAN_COMMON_LANGOPTIONS_H
-#define FORTRAN_COMMON_LANGOPTIONS_H
+#ifndef FORTRAN_SUPPORT_LANGOPTIONS_H_
+#define FORTRAN_SUPPORT_LANGOPTIONS_H_
 
 #include <string>
 #include <vector>
@@ -45,12 +45,12 @@ class LangOptionsBase {
 
 #define LANGOPT(Name, Bits, Default) unsigned Name : Bits;
 #define ENUM_LANGOPT(Name, Type, Bits, Default)
-#include "flang/Common/LangOptions.def"
+#include "flang/Support/LangOptions.def"
 
 protected:
 #define LANGOPT(Name, Bits, Default)
 #define ENUM_LANGOPT(Name, Type, Bits, Default) unsigned Name : Bits;
-#include "flang/Common/LangOptions.def"
+#include "flang/Support/LangOptions.def"
 };
 
 /// Tracks various options which control the dialect of Fortran that is
@@ -63,7 +63,7 @@ class LangOptions : public LangOptionsBase {
 #define ENUM_LANGOPT(Name, Type, Bits, Default) \
   Type get##Name() const { return static_cast<Type>(Name); } \
   void set##Name(Type Value) { Name = static_cast<unsigned>(Value); }
-#include "flang/Common/LangOptions.def"
+#include "flang/Support/LangOptions.def"
 
   /// Name of the IR file that contains the result of the OpenMP target
   /// host code generation.
@@ -77,4 +77,4 @@ class LangOptions : public LangOptionsBase {
 
 } // end namespace Fortran::common
 
-#endif // FORTRAN_COMMON_LANGOPTIONS_H
+#endif /* FORTRAN_SUPPORT_LANGOPTIONS_H_ */
diff --git a/flang/include/flang/Common/MathOptionsBase.def b/flang/include/flang/Support/MathOptionsBase.def
similarity index 100%
rename from flang/include/flang/Common/MathOptionsBase.def
rename to flang/include/flang/Support/MathOptionsBase.def
diff --git a/flang/include/flang/Common/MathOptionsBase.h b/flang/include/flang/Support/MathOptionsBase.h
similarity index 77%
rename from flang/include/flang/Common/MathOptionsBase.h
rename to flang/include/flang/Support/MathOptionsBase.h
index 7f8ebdbee19878..072aed20da4708 100644
--- a/flang/include/flang/Common/MathOptionsBase.h
+++ b/flang/include/flang/Support/MathOptionsBase.h
@@ -1,4 +1,4 @@
-//===- MathOptionsBase.h - Math options config ------------------*- C++ -*-===//
+//===-- include/flang/Support/MathOptionsBase.h -----------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -14,8 +14,8 @@
 ///
 //===----------------------------------------------------------------------===//
 
-#ifndef FORTRAN_COMMON_MATHOPTIONSBASE_H
-#define FORTRAN_COMMON_MATHOPTIONSBASE_H
+#ifndef FORTRAN_SUPPORT_MATHOPTIONSBASE_H_
+#define FORTRAN_SUPPORT_MATHOPTIONSBASE_H_
 
 namespace Fortran::common {
 
@@ -27,18 +27,18 @@ class MathOptionsBase {
     Name = static_cast<unsigned>(Value); \
     return *this; \
   }
-#include "flang/Common/MathOptionsBase.def"
+#include "flang/Support/MathOptionsBase.def"
 
   MathOptionsBase() {
 #define ENUM_MATHOPT(Name, Type, Bits, Default) set##Name(Default);
-#include "flang/Common/MathOptionsBase.def"
+#include "flang/Support/MathOptionsBase.def"
   }
 
 private:
 #define ENUM_MATHOPT(Name, Type, Bits, Default) unsigned Name : Bits;
-#include "flang/Common/MathOptionsBase.def"
+#include "flang/Support/MathOptionsBase.def"
 };
 
 } // namespace Fortran::common
 
-#endif // FORTRAN_COMMON_MATHOPTIONSBASE_H
+#endif /* FORTRAN_SUPPORT_MATHOPTIONSBASE_H_ */
diff --git a/flang/include/flang/Common/OpenMP-features.h b/flang/include/flang/Support/OpenMP-features.h
similarity index 85%
rename from flang/include/flang/Common/OpenMP-features.h
rename to flang/include/flang/Support/OpenMP-features.h
index 480c8b4c1013fe..85c901e7fdb82f 100644
--- a/flang/include/flang/Common/OpenMP-features.h
+++ b/flang/include/flang/Support/OpenMP-features.h
@@ -1,4 +1,4 @@
-//===-- include/flang/Common/OpenMP-features.h -----------------*- C++ -*-====//
+//===-- include/flang/Support/OpenMP-features.h -----------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -6,8 +6,8 @@
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef FORTRAN_COMMON_OPENMP_FEATURES_H_
-#define FORTRAN_COMMON_OPENMP_FEATURES_H_
+#ifndef FORTRAN_SUPPORT_OPENMP_FEATURES_H_
+#define FORTRAN_SUPPORT_OPENMP_FEATURES_H_
 
 namespace Fortran::common {
 
@@ -49,4 +49,4 @@ void setOpenMPMacro(int version, FortranPredefinitions &predefinitions) {
   }
 }
 } // namespace Fortran::common
-#endif // FORTRAN_COMMON_OPENMP_FEATURES_H_
+#endif /* FORTRAN_SUPPORT_OPENMP_FEATURES_H_ */
diff --git a/flang/include/flang/Common/Version.h b/flang/include/flang/Support/Version.h
similarity index 90%
rename from flang/include/flang/Common/Version.h
rename to flang/include/flang/Support/Version.h
index 3257d4a4f64593..4ceb19e7f4d714 100644
--- a/flang/include/flang/Common/Version.h
+++ b/flang/include/flang/Support/Version.h
@@ -1,4 +1,4 @@
-//===- Version.h - Flang Version Number ---------------------*- Fortran -*-===//
+//===-- include/flang/Support/Version.h -------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -12,8 +12,8 @@
 ///
 //===----------------------------------------------------------------------===//
 
-#ifndef FORTRAN_COMMON_VERSION_H
-#define FORTRAN_COMMON_VERSION_H
+#ifndef FORTRAN_SUPPORT_VERSION_H_
+#define FORTRAN_SUPPORT_VERSION_H_
 
 #include "flang/Version.inc"
 #include "llvm/ADT/StringRef.h"
@@ -53,4 +53,4 @@ std::string getFlangFullVersion();
 std::string getFlangToolFullVersion(llvm::StringRef ToolName);
 } // namespace Fortran::common
 
-#endif // FORTRAN_COMMON_VERSION_H
+#endif /* FORTRAN_SUPPORT_VERSION_H_ */
diff --git a/flang/include/flang/Common/default-kinds.h b/flang/include/flang/Support/default-kinds.h
similarity index 91%
rename from flang/include/flang/Common/default-kinds.h
rename to flang/include/flang/Support/default-kinds.h
index 6c66b98e98a05b..92f06e6fe2d272 100644
--- a/flang/include/flang/Common/default-kinds.h
+++ b/flang/include/flang/Support/default-kinds.h
@@ -1,4 +1,4 @@
-//===-- include/flang/Common/default-kinds.h --------------------*- C++ -*-===//
+//===-- include/flang/Support/default-kinds.h -------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -6,10 +6,10 @@
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef FORTRAN_COMMON_DEFAULT_KINDS_H_
-#define FORTRAN_COMMON_DEFAULT_KINDS_H_
+#ifndef FORTRAN_SUPPORT_DEFAULT_KINDS_H_
+#define FORTRAN_SUPPORT_DEFAULT_KINDS_H_
 
-#include "flang/Common/Fortran.h"
+#include "flang/Support/Fortran.h"
 #include <cstdint>
 
 namespace Fortran::common {
@@ -58,4 +58,4 @@ class IntrinsicTypeDefaultKinds {
   int defaultLogicalKind_{defaultIntegerKind_};
 };
 } // namespace Fortran::common
-#endif // FORTRAN_COMMON_DEFAULT_KINDS_H_
+#endif /* FORTRAN_SUPPORT_DEFAULT_KINDS_H_ */
diff --git a/flang/include/flang/Common/indirection.h b/flang/include/flang/Support/indirection.h
similarity index 95%
rename from flang/include/flang/Common/indirection.h
rename to flang/include/flang/Support/indirection.h
index 7348eb0473f072..aeb1698516bae9 100644
--- a/flang/include/flang/Common/indirection.h
+++ b/flang/include/flang/Support/indirection.h
@@ -1,4 +1,4 @@
-//===-- include/flang/Common/indirection.h ----------------------*- C++ -*-===//
+//===-- include/flang/Support/indirection.h ---------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -6,8 +6,8 @@
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef FORTRAN_COMMON_INDIRECTION_H_
-#define FORTRAN_COMMON_INDIRECTION_H_
+#ifndef FORTRAN_SUPPORT_INDIRECTION_H_
+#define FORTRAN_SUPPORT_INDIRECTION_H_
 
 // Define a smart pointer class template that is rather like
 // non-nullable std::unique_ptr<>.  Indirection<> is, like a C++ reference
@@ -20,7 +20,7 @@
 //    template class Fortran::common::Indirection<FORWARD_TYPE>;
 // in one C++ source file later where a definition of the type is visible.
 
-#include "idioms.h"
+#include "flang/Common/idioms.h"
 #include <memory>
 #include <type_traits>
 #include <utility>
@@ -171,4 +171,4 @@ template <typename A> class ForwardOwningPointer {
   void (*deleter_)(A *){nullptr};
 };
 } // namespace Fortran::common
-#endif // FORTRAN_COMMON_INDIRECTION_H_
+#endif /* FORTRAN_SUPPORT_INDIRECTION_H_ */
diff --git a/flang/include/flang/Common/interval.h b/flang/include/flang/Support/interval.h
similarity index 94%
rename from flang/include/flang/Common/interval.h
rename to flang/include/flang/Support/interval.h
index c4cab0ccf1130b..99c0784f006a80 100644
--- a/flang/include/flang/Common/interval.h
+++ b/flang/include/flang/Support/interval.h
@@ -1,4 +1,4 @@
-//===-- include/flang/Common/interval.h -------------------------*- C++ -*-===//
+//===-- include/flang/Support/interval.h ------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -6,13 +6,13 @@
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef FORTRAN_COMMON_INTERVAL_H_
-#define FORTRAN_COMMON_INTERVAL_H_
+#ifndef FORTRAN_SUPPORT_INTERVAL_H_
+#define FORTRAN_SUPPORT_INTERVAL_H_
 
 // Defines a generalized template class Interval<A> to represent
 // the half-open interval [x .. x+n).
 
-#include "idioms.h"
+#include "flang/Common/idioms.h"
 #include <algorithm>
 #include <cstddef>
 #include <utility>
@@ -126,4 +126,4 @@ template <typename A> class Interval {
   std::size_t size_{0};
 };
 } // namespace Fortran::common
-#endif // FORTRAN_COMMON_INTERVAL_H_
+#endif /* FORTRAN_SUPPORT_INTERVAL_H_ */
diff --git a/flang/include/flang/Common/reference-counted.h b/flang/include/flang/Support/reference-counted.h
similarity index 90%
rename from flang/include/flang/Common/reference-counted.h
rename to flang/include/flang/Support/reference-counted.h
index de91d4fb6ee8b7..636613d93d80cc 100644
--- a/flang/include/flang/Common/reference-counted.h
+++ b/flang/include/flang/Support/reference-counted.h
@@ -1,4 +1,4 @@
-//===-- include/flang/Common/reference-counted.h ----------------*- C++ -*-===//
+//===-- include/flang/Support/reference-counted.h ---------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -6,8 +6,8 @@
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef FORTRAN_COMMON_REFERENCE_COUNTED_H_
-#define FORTRAN_COMMON_REFERENCE_COUNTED_H_
+#ifndef FORTRAN_SUPPORT_REFERENCE_COUNTED_H_
+#define FORTRAN_SUPPORT_REFERENCE_COUNTED_H_
 
 // A class template of smart pointers to objects with their own
 // reference counting object lifetimes that's lighter weight
@@ -74,4 +74,4 @@ template <typename A> class CountedReference {
   type *p_{nullptr};
 };
 } // namespace Fortran::common
-#endif // FORTRAN_COMMON_REFERENCE_COUNTED_H_
+#endif /* FORTRAN_SUPPORT_REFERENCE_COUNTED_H_ */
diff --git a/flang/include/flang/Common/reference.h b/flang/include/flang/Support/reference.h
similarity index 91%
rename from flang/include/flang/Common/reference.h
rename to flang/include/flang/Support/reference.h
index 0c579de44bd7fa..c0b0e048ae04a7 100644
--- a/flang/include/flang/Common/reference.h
+++ b/flang/include/flang/Support/reference.h
@@ -1,4 +1,4 @@
-//===-- include/flang/Common/reference.h ------------------------*- C++ -*-===//
+//===-- include/flang/Support/reference.h -----------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -11,8 +11,8 @@
 // Use Reference<A> in place of a real A& reference when assignability is
 // required; safer than a bare pointer because it's guaranteed to not be null.
 
-#ifndef FORTRAN_COMMON_REFERENCE_H_
-#define FORTRAN_COMMON_REFERENCE_H_
+#ifndef FORTRAN_SUPPORT_REFERENCE_H_
+#define FORTRAN_SUPPORT_REFERENCE_H_
 #include <type_traits>
 namespace Fortran::common {
 template <typename A> class Reference {
@@ -60,4 +60,4 @@ template <typename A> class Reference {
 };
 template <typename A> Reference(A &) -> Reference<A>;
 } // namespace Fortran::common
-#endif
+#endif /* FORTRAN_SUPPORT_REFERENCE_H_ */
diff --git a/flang/include/flang/Common/static-multimap-view.h b/flang/include/flang/Support/static-multimap-view.h
similarity index 91%
rename from flang/include/flang/Common/static-multimap-view.h
rename to flang/include/flang/Support/static-multimap-view.h
index 27d2ba89c8009c..8928fab6bfb6f5 100644
--- a/flang/include/flang/Common/static-multimap-view.h
+++ b/flang/include/flang/Support/static-multimap-view.h
@@ -1,4 +1,4 @@
-//===-- include/flang/Common/static-multimap-view.h -------------*- C++ -*-===//
+//===-- include/flang/Support/static-multimap-view.h ------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -6,8 +6,8 @@
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef FORTRAN_COMMON_STATIC_MULTIMAP_VIEW_H_
-#define FORTRAN_COMMON_STATIC_MULTIMAP_VIEW_H_
+#ifndef FORTRAN_SUPPORT_STATIC_MULTIMAP_VIEW_H_
+#define FORTRAN_SUPPORT_STATIC_MULTIMAP_VIEW_H_
 #include <algorithm>
 #include <utility>
 
@@ -59,4 +59,4 @@ template <typename V> class StaticMultimapView {
   const_iterator end_{nullptr};
 };
 } // namespace Fortran::common
-#endif // FORTRAN_COMMON_STATIC_MULTIMAP_VIEW_H_
+#endif /* FORTRAN_SUPPORT_STATIC_MULTIMAP_VIEW_H_ */
diff --git a/flang/include/flang/Common/template.h b/flang/include/flang/Support/template.h
similarity index 98%
rename from flang/include/flang/Common/template.h
rename to flang/include/flang/Support/template.h
index 51d09fb42ce368..36fa6f7072b40c 100644
--- a/flang/include/flang/Common/template.h
+++ b/flang/include/flang/Support/template.h
@@ -1,4 +1,4 @@
-//===-- include/flang/Common/template.h -------------------------*- C++ -*-===//
+//===-- include/flang/Support/template.h ------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -6,11 +6,11 @@
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef FORTRAN_COMMON_TEMPLATE_H_
-#define FORTRAN_COMMON_TEMPLATE_H_
+#ifndef FORTRAN_SUPPORT_TEMPLATE_H_
+#define FORTRAN_SUPPORT_TEMPLATE_H_
 
-#include "variant.h"
 #include "flang/Common/idioms.h"
+#include "flang/Common/variant.h"
 #include <functional>
 #include <optional>
 #include <tuple>
@@ -322,4 +322,4 @@ common::IfNoLvalue<typename VISITOR::Result, VISITOR> SearchTypes(
       std::move(visitor), std::move(defaultResult));
 }
 } // namespace Fortran::common
-#endif // FORTRAN_COMMON_TEMPLATE_H_
+#endif /* FORTRAN_SUPPORT_TEMPLATE_H_ */
diff --git a/flang/include/flang/Common/unwrap.h b/flang/include/flang/Support/unwrap.h
similarity index 94%
rename from flang/include/flang/Common/unwrap.h
rename to flang/include/flang/Support/unwrap.h
index 84582174e4b300..e890753499d1a1 100644
--- a/flang/include/flang/Common/unwrap.h
+++ b/flang/include/flang/Support/unwrap.h
@@ -1,4 +1,4 @@
-//===-- include/flang/Common/unwrap.h ---------------------------*- C++ -*-===//
+//===-- include/flang/Support/unwrap.h --------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -6,14 +6,14 @@
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef FORTRAN_COMMON_UNWRAP_H_
-#define FORTRAN_COMMON_UNWRAP_H_
+#ifndef FORTRAN_SUPPORT_UNWRAP_H_
+#define FORTRAN_SUPPORT_UNWRAP_H_
 
 #include "indirection.h"
 #include "reference-counted.h"
 #include "reference.h"
-#include "variant.h"
-#include "visit.h"
+#include "flang/Common/variant.h"
+#include "flang/Common/visit.h"
 #include <memory>
 #include <optional>
 #include <type_traits>
@@ -155,4 +155,4 @@ template <typename A, typename B> std::optional<A> UnwrapCopy(const B &x) {
   }
 }
 } // namespace Fortran::common
-#endif // FORTRAN_COMMON_UNWRAP_H_
+#endif /* FORTRAN_SUPPORT_UNWRAP_H_ */
diff --git a/flang/include/flang/Tools/CrossToolHelpers.h b/flang/include/flang/Tools/CrossToolHelpers.h
index 0286f2aa145192..d9401e753fb796 100644
--- a/flang/include/flang/Tools/CrossToolHelpers.h
+++ b/flang/include/flang/Tools/CrossToolHelpers.h
@@ -13,9 +13,9 @@
 #ifndef FORTRAN_TOOLS_CROSS_TOOL_HELPERS_H
 #define FORTRAN_TOOLS_CROSS_TOOL_HELPERS_H
 
-#include "flang/Common/LangOptions.h"
-#include "flang/Common/MathOptionsBase.h"
 #include "flang/Frontend/CodeGenOptions.h"
+#include "flang/Support/LangOptions.h"
+#include "flang/Support/MathOptionsBase.h"
 #include <cstdint>
 
 #include "mlir/Dialect/OpenMP/OpenMPDialect.h"
diff --git a/flang/lib/CMakeLists.txt b/flang/lib/CMakeLists.txt
index e5a5e504ec1a4e..0ab7d1c888df96 100644
--- a/flang/lib/CMakeLists.txt
+++ b/flang/lib/CMakeLists.txt
@@ -1,4 +1,5 @@
 add_subdirectory(Common)
+add_subdirectory(Support)
 add_subdirectory(Evaluate)
 add_subdirectory(Lower)
 add_subdirectory(Parser)
diff --git a/flang/lib/Common/CMakeLists.txt b/flang/lib/Common/CMakeLists.txt
index 3e5f0b13af8881..e5d9c9eb8c3f19 100644
--- a/flang/lib/Common/CMakeLists.txt
+++ b/flang/lib/Common/CMakeLists.txt
@@ -1,54 +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()
+#===-- 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
   binary-to-decimal.cpp
   decimal-to-binary.cpp
-  Fortran.cpp
-  Fortran-features.cpp
-  default-kinds.cpp
-  idioms.cpp
-  LangOptions.cpp
-  OpenMP-utils.cpp
-  Version.cpp
-  ${version_inc}
-
-  LINK_COMPONENTS
-  Support
-
-  LINK_LIBS
-  MLIRIR
 )
diff --git a/flang/lib/Evaluate/CMakeLists.txt b/flang/lib/Evaluate/CMakeLists.txt
index ebdc55cff91c43..1408f382255a8b 100644
--- a/flang/lib/Evaluate/CMakeLists.txt
+++ b/flang/lib/Evaluate/CMakeLists.txt
@@ -61,6 +61,7 @@ add_flang_library(FortranEvaluate
 
   LINK_LIBS
   FortranCommon
+  FortranSupport
   FortranParser
   ${LIBPGMATH}
   ${QUADMATHLIB}
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 324d6b8dde73b8..6a55012dcebdc2 100644
--- a/flang/lib/Evaluate/characteristics.cpp
+++ b/flang/lib/Evaluate/characteristics.cpp
@@ -7,7 +7,6 @@
 //===----------------------------------------------------------------------===//
 
 #include "flang/Evaluate/characteristics.h"
-#include "flang/Common/indirection.h"
 #include "flang/Evaluate/check-expression.h"
 #include "flang/Evaluate/fold.h"
 #include "flang/Evaluate/intrinsics.h"
@@ -17,6 +16,7 @@
 #include "flang/Semantics/scope.h"
 #include "flang/Semantics/symbol.h"
 #include "flang/Semantics/tools.h"
+#include "flang/Support/indirection.h"
 #include "llvm/Support/raw_ostream.h"
 #include <initializer_list>
 
diff --git a/flang/lib/Evaluate/fold-implementation.h b/flang/lib/Evaluate/fold-implementation.h
index c82995c38f79f7..4a5a27a7686061 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 f3a53c1f983dfa..c4c39982578301 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 c1b270f518c0e0..fa2c931b21f0aa 100644
--- a/flang/lib/Evaluate/intrinsics-library.cpp
+++ b/flang/lib/Evaluate/intrinsics-library.cpp
@@ -16,8 +16,8 @@
 #include "host.h"
 #include "flang/Common/erfc-scaled.h"
 #include "flang/Common/idioms.h"
-#include "flang/Common/static-multimap-view.h"
 #include "flang/Evaluate/expression.h"
+#include "flang/Support/static-multimap-view.h"
 #include <cfloat>
 #include <cmath>
 #include <complex>
diff --git a/flang/lib/Evaluate/intrinsics.cpp b/flang/lib/Evaluate/intrinsics.cpp
index 28805efb177ee2..be9abb3a0cc30d 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 af6df14f119c53..4c78a0ab658e0e 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 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 409e28c767e1e1..beff35c2417a21 100644
--- a/flang/lib/Evaluate/target.cpp
+++ b/flang/lib/Evaluate/target.cpp
@@ -7,9 +7,9 @@
 //===----------------------------------------------------------------------===//
 
 #include "flang/Evaluate/target.h"
-#include "flang/Common/template.h"
 #include "flang/Evaluate/common.h"
 #include "flang/Evaluate/type.h"
+#include "flang/Support/template.h"
 
 namespace Fortran::evaluate {
 
diff --git a/flang/lib/Frontend/CMakeLists.txt b/flang/lib/Frontend/CMakeLists.txt
index e954800c3b88b0..7078c911660bdb 100644
--- a/flang/lib/Frontend/CMakeLists.txt
+++ b/flang/lib/Frontend/CMakeLists.txt
@@ -28,6 +28,7 @@ add_flang_library(flangFrontend
   FortranSemantics
   FortranEvaluate
   FortranCommon
+  FortranSupport
   FortranLower
   FIRDialect
   FIRDialectSupport
diff --git a/flang/lib/Frontend/CompilerInstance.cpp b/flang/lib/Frontend/CompilerInstance.cpp
index 35c2ae3c73e69e..fe242cdb3586e0 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 79386c92d552ca..22676f34370119 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 603cb039d20b14..51139a6d37254a 100644
--- a/flang/lib/Frontend/FrontendActions.cpp
+++ b/flang/lib/Frontend/FrontendActions.cpp
@@ -11,7 +11,6 @@
 //===----------------------------------------------------------------------===//
 
 #include "flang/Frontend/FrontendActions.h"
-#include "flang/Common/default-kinds.h"
 #include "flang/Frontend/CompilerInstance.h"
 #include "flang/Frontend/CompilerInvocation.h"
 #include "flang/Frontend/FrontendOptions.h"
@@ -34,6 +33,7 @@
 #include "flang/Semantics/runtime-type-info.h"
 #include "flang/Semantics/semantics.h"
 #include "flang/Semantics/unparse-with-symbols.h"
+#include "flang/Support/default-kinds.h"
 #include "flang/Tools/CrossToolHelpers.h"
 
 #include "mlir/IR/Dialect.h"
diff --git a/flang/lib/Lower/Bridge.cpp b/flang/lib/Lower/Bridge.cpp
index c7bf4248155483..9cc6acb0a75262 100644
--- a/flang/lib/Lower/Bridge.cpp
+++ b/flang/lib/Lower/Bridge.cpp
@@ -12,7 +12,6 @@
 
 #include "flang/Lower/Bridge.h"
 
-#include "flang/Common/Version.h"
 #include "flang/Lower/Allocatable.h"
 #include "flang/Lower/CallInterface.h"
 #include "flang/Lower/Coarray.h"
@@ -62,6 +61,7 @@
 #include "flang/Semantics/runtime-type-info.h"
 #include "flang/Semantics/symbol.h"
 #include "flang/Semantics/tools.h"
+#include "flang/Support/Version.h"
 #include "mlir/Dialect/ControlFlow/IR/ControlFlowOps.h"
 #include "mlir/IR/Matchers.h"
 #include "mlir/IR/PatternMatch.h"
diff --git a/flang/lib/Lower/CMakeLists.txt b/flang/lib/Lower/CMakeLists.txt
index ba6622d8504a4f..7885c96f4b6273 100644
--- a/flang/lib/Lower/CMakeLists.txt
+++ b/flang/lib/Lower/CMakeLists.txt
@@ -57,6 +57,7 @@ add_flang_library(FortranLower
   ${dialect_libs}
   ${extension_libs}
   FortranCommon
+  FortranSupport
   FortranParser
   FortranEvaluate
   FortranSemantics
diff --git a/flang/lib/Lower/CallInterface.cpp b/flang/lib/Lower/CallInterface.cpp
index e20b90b2ff1bcb..c8314fac9054c4 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 d9ae502edbafaa..04df137ce566ff 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 1165417ef89a28..aa40b121965202 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 9a3777994a9df0..9781e842a56aab 100644
--- a/flang/lib/Optimizer/Builder/IntrinsicCall.cpp
+++ b/flang/lib/Optimizer/Builder/IntrinsicCall.cpp
@@ -14,7 +14,6 @@
 //===----------------------------------------------------------------------===//
 
 #include "flang/Optimizer/Builder/IntrinsicCall.h"
-#include "flang/Common/static-multimap-view.h"
 #include "flang/Optimizer/Builder/BoxValue.h"
 #include "flang/Optimizer/Builder/Character.h"
 #include "flang/Optimizer/Builder/Complex.h"
@@ -42,6 +41,7 @@
 #include "flang/Optimizer/Support/Utils.h"
 #include "flang/Runtime/entry-names.h"
 #include "flang/Runtime/iostat-consts.h"
+#include "flang/Support/static-multimap-view.h"
 #include "mlir/Dialect/Complex/IR/Complex.h"
 #include "mlir/Dialect/LLVMIR/LLVMDialect.h"
 #include "mlir/Dialect/Math/IR/Math.h"
@@ -778,7 +778,7 @@ prettyPrintIntrinsicName(fir::FirOpBuilder &builder, mlir::Location loc,
 // Generate a call to the Fortran runtime library providing
 // support for 128-bit float math.
 // On 'HAS_LDBL128' targets the implementation
-// is provided by FortranRuntime, otherwise, it is done via
+// is provided by flang_rt, otherwise, it is done via
 // FortranFloat128Math library. In the latter case the compiler
 // has to be built with FLANG_RUNTIME_F128_MATH_LIB to guarantee
 // proper linking actions in the driver.
diff --git a/flang/lib/Optimizer/CodeGen/TypeConverter.cpp b/flang/lib/Optimizer/CodeGen/TypeConverter.cpp
index c23203efcd3df2..c9544c59299933 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 cba7fa64128502..8e5cf7f251501b 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"
@@ -1419,4 +1419,4 @@ fir::getTypeSizeAndAlignmentOrCrash(mlir::Location loc, mlir::Type ty,
   if (result)
     return *result;
   TODO(loc, "computing size of a component");
-}
+}
\ No newline at end of file
diff --git a/flang/lib/Optimizer/OpenMP/CMakeLists.txt b/flang/lib/Optimizer/OpenMP/CMakeLists.txt
index 026889cca238a0..a54062fecff50a 100644
--- a/flang/lib/Optimizer/OpenMP/CMakeLists.txt
+++ b/flang/lib/Optimizer/OpenMP/CMakeLists.txt
@@ -22,6 +22,7 @@ add_flang_library(FlangOpenMPTransforms
   FIRDialectSupport
   FIRSupport
   FortranCommon
+  FortranSupport
   FortranEvaluate
   MLIRFuncDialect
   MLIROpenMPDialect
diff --git a/flang/lib/Optimizer/Passes/CMakeLists.txt b/flang/lib/Optimizer/Passes/CMakeLists.txt
index 40abbdfbdd6511..029588dc7f7bbe 100644
--- a/flang/lib/Optimizer/Passes/CMakeLists.txt
+++ b/flang/lib/Optimizer/Passes/CMakeLists.txt
@@ -5,9 +5,6 @@ add_flang_library(flangPasses
   CommandLineOpts.cpp
   Pipelines.cpp
 
-  DEPENDS
-  FortranCommon
-
   LINK_LIBS
   FIRCodeGen
   FIRTransforms
@@ -15,6 +12,7 @@ add_flang_library(flangPasses
   ${dialect_libs}
   ${extension_libs}
   FortranCommon
+  FortranSupport
   HLFIRTransforms
   MLIRPass
   MLIRReconcileUnrealizedCasts
diff --git a/flang/lib/Optimizer/Transforms/AddDebugInfo.cpp b/flang/lib/Optimizer/Transforms/AddDebugInfo.cpp
index a8e9d198ccb97c..79e2b360018c15 100644
--- a/flang/lib/Optimizer/Transforms/AddDebugInfo.cpp
+++ b/flang/lib/Optimizer/Transforms/AddDebugInfo.cpp
@@ -12,7 +12,6 @@
 //===----------------------------------------------------------------------===//
 
 #include "DebugTypeGenerator.h"
-#include "flang/Common/Version.h"
 #include "flang/Optimizer/Builder/FIRBuilder.h"
 #include "flang/Optimizer/Builder/Todo.h"
 #include "flang/Optimizer/CodeGen/CGOps.h"
@@ -23,6 +22,7 @@
 #include "flang/Optimizer/Dialect/Support/FIRContext.h"
 #include "flang/Optimizer/Support/InternalNames.h"
 #include "flang/Optimizer/Transforms/Passes.h"
+#include "flang/Support/Version.h"
 #include "mlir/Dialect/Func/IR/FuncOps.h"
 #include "mlir/Dialect/LLVMIR/LLVMDialect.h"
 #include "mlir/IR/Matchers.h"
diff --git a/flang/lib/Optimizer/Transforms/AssumedRankOpConversion.cpp b/flang/lib/Optimizer/Transforms/AssumedRankOpConversion.cpp
index eb59045a5fde7f..d0bd67a2364198 100644
--- a/flang/lib/Optimizer/Transforms/AssumedRankOpConversion.cpp
+++ b/flang/lib/Optimizer/Transforms/AssumedRankOpConversion.cpp
@@ -6,7 +6,6 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "flang/Common/Fortran.h"
 #include "flang/Lower/BuiltinModules.h"
 #include "flang/Optimizer/Builder/FIRBuilder.h"
 #include "flang/Optimizer/Builder/Runtime/Support.h"
@@ -17,6 +16,7 @@
 #include "flang/Optimizer/Support/Utils.h"
 #include "flang/Optimizer/Transforms/Passes.h"
 #include "flang/Runtime/support.h"
+#include "flang/Support/Fortran.h"
 #include "mlir/Dialect/Func/IR/FuncOps.h"
 #include "mlir/Pass/Pass.h"
 #include "mlir/Transforms/DialectConversion.h"
diff --git a/flang/lib/Optimizer/Transforms/CMakeLists.txt b/flang/lib/Optimizer/Transforms/CMakeLists.txt
index d20d3bc4108ce9..66c0a6dab1f2d2 100644
--- a/flang/lib/Optimizer/Transforms/CMakeLists.txt
+++ b/flang/lib/Optimizer/Transforms/CMakeLists.txt
@@ -47,6 +47,7 @@ add_flang_library(FIRTransforms
   FIRDialectSupport
   FIRSupport
   FortranCommon
+  FortranSupport
   HLFIRDialect
   MLIRAffineUtils
   MLIRFuncDialect
diff --git a/flang/lib/Optimizer/Transforms/CUFDeviceGlobal.cpp b/flang/lib/Optimizer/Transforms/CUFDeviceGlobal.cpp
index 2e6c272fa90891..d4c9e002f739b3 100644
--- a/flang/lib/Optimizer/Transforms/CUFDeviceGlobal.cpp
+++ b/flang/lib/Optimizer/Transforms/CUFDeviceGlobal.cpp
@@ -6,7 +6,6 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "flang/Common/Fortran.h"
 #include "flang/Optimizer/Builder/CUFCommon.h"
 #include "flang/Optimizer/Dialect/CUF/CUFOps.h"
 #include "flang/Optimizer/Dialect/FIRDialect.h"
@@ -15,6 +14,7 @@
 #include "flang/Optimizer/Support/InternalNames.h"
 #include "flang/Runtime/CUDA/common.h"
 #include "flang/Runtime/allocatable.h"
+#include "flang/Support/Fortran.h"
 #include "mlir/Dialect/LLVMIR/NVVMDialect.h"
 #include "mlir/IR/SymbolTable.h"
 #include "mlir/Pass/Pass.h"
diff --git a/flang/lib/Optimizer/Transforms/CUFGPUToLLVMConversion.cpp b/flang/lib/Optimizer/Transforms/CUFGPUToLLVMConversion.cpp
index 60aa401e1cc8cc..5a3d38722ecd31 100644
--- a/flang/lib/Optimizer/Transforms/CUFGPUToLLVMConversion.cpp
+++ b/flang/lib/Optimizer/Transforms/CUFGPUToLLVMConversion.cpp
@@ -7,10 +7,10 @@
 //===----------------------------------------------------------------------===//
 
 #include "flang/Optimizer/Transforms/CUFGPUToLLVMConversion.h"
-#include "flang/Common/Fortran.h"
 #include "flang/Optimizer/CodeGen/TypeConverter.h"
 #include "flang/Optimizer/Support/DataLayout.h"
 #include "flang/Runtime/CUDA/common.h"
+#include "flang/Support/Fortran.h"
 #include "mlir/Conversion/LLVMCommon/Pattern.h"
 #include "mlir/Dialect/GPU/IR/GPUDialect.h"
 #include "mlir/Pass/Pass.h"
diff --git a/flang/lib/Optimizer/Transforms/CUFOpConversion.cpp b/flang/lib/Optimizer/Transforms/CUFOpConversion.cpp
index 8c525fc6daff5e..ea2cd7e0b12d21 100644
--- a/flang/lib/Optimizer/Transforms/CUFOpConversion.cpp
+++ b/flang/lib/Optimizer/Transforms/CUFOpConversion.cpp
@@ -7,7 +7,6 @@
 //===----------------------------------------------------------------------===//
 
 #include "flang/Optimizer/Transforms/CUFOpConversion.h"
-#include "flang/Common/Fortran.h"
 #include "flang/Optimizer/Builder/CUFCommon.h"
 #include "flang/Optimizer/Builder/Runtime/RTBuilder.h"
 #include "flang/Optimizer/CodeGen/TypeConverter.h"
@@ -21,6 +20,7 @@
 #include "flang/Runtime/CUDA/descriptor.h"
 #include "flang/Runtime/CUDA/memory.h"
 #include "flang/Runtime/allocatable.h"
+#include "flang/Support/Fortran.h"
 #include "mlir/Conversion/LLVMCommon/Pattern.h"
 #include "mlir/Dialect/GPU/IR/GPUDialect.h"
 #include "mlir/IR/Matchers.h"
diff --git a/flang/lib/Optimizer/Transforms/ExternalNameConversion.cpp b/flang/lib/Optimizer/Transforms/ExternalNameConversion.cpp
index 4f6974ee526955..3d84eaa4c1595a 100644
--- a/flang/lib/Optimizer/Transforms/ExternalNameConversion.cpp
+++ b/flang/lib/Optimizer/Transforms/ExternalNameConversion.cpp
@@ -6,12 +6,12 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "flang/Common/Fortran.h"
 #include "flang/Optimizer/Dialect/FIRDialect.h"
 #include "flang/Optimizer/Dialect/FIROps.h"
 #include "flang/Optimizer/Dialect/FIROpsSupport.h"
 #include "flang/Optimizer/Support/InternalNames.h"
 #include "flang/Optimizer/Transforms/Passes.h"
+#include "flang/Support/Fortran.h"
 #include "mlir/Dialect/GPU/IR/GPUDialect.h"
 #include "mlir/IR/Attributes.h"
 #include "mlir/IR/SymbolTable.h"
diff --git a/flang/lib/Optimizer/Transforms/LoopVersioning.cpp b/flang/lib/Optimizer/Transforms/LoopVersioning.cpp
index b534ec160ce215..343cc6ff289500 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 fa6a7b23624e84..df2887ff1422e7 100644
--- a/flang/lib/Optimizer/Transforms/SimplifyIntrinsics.cpp
+++ b/flang/lib/Optimizer/Transforms/SimplifyIntrinsics.cpp
@@ -22,7 +22,6 @@
 /// and small in size.
 //===----------------------------------------------------------------------===//
 
-#include "flang/Common/Fortran.h"
 #include "flang/Optimizer/Builder/BoxValue.h"
 #include "flang/Optimizer/Builder/CUFCommon.h"
 #include "flang/Optimizer/Builder/FIRBuilder.h"
@@ -35,6 +34,7 @@
 #include "flang/Optimizer/Transforms/Passes.h"
 #include "flang/Optimizer/Transforms/Utils.h"
 #include "flang/Runtime/entry-names.h"
+#include "flang/Support/Fortran.h"
 #include "mlir/Dialect/LLVMIR/LLVMDialect.h"
 #include "mlir/IR/Matchers.h"
 #include "mlir/IR/Operation.h"
diff --git a/flang/lib/Optimizer/Transforms/StackReclaim.cpp b/flang/lib/Optimizer/Transforms/StackReclaim.cpp
index bd3e49a47bc399..acb685850d173c 100644
--- a/flang/lib/Optimizer/Transforms/StackReclaim.cpp
+++ b/flang/lib/Optimizer/Transforms/StackReclaim.cpp
@@ -6,11 +6,11 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "flang/Common/Fortran.h"
 #include "flang/Optimizer/Builder/FIRBuilder.h"
 #include "flang/Optimizer/Dialect/FIRDialect.h"
 #include "flang/Optimizer/Dialect/FIROps.h"
 #include "flang/Optimizer/Transforms/Passes.h"
+#include "flang/Support/Fortran.h"
 #include "mlir/Dialect/LLVMIR/LLVMDialect.h"
 #include "mlir/IR/Matchers.h"
 #include "mlir/Pass/Pass.h"
diff --git a/flang/lib/Optimizer/Transforms/VScaleAttr.cpp b/flang/lib/Optimizer/Transforms/VScaleAttr.cpp
index 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 d364671d7a3229..96ee72a6e7a912 100644
--- a/flang/lib/Parser/CMakeLists.txt
+++ b/flang/lib/Parser/CMakeLists.txt
@@ -26,6 +26,7 @@ add_flang_library(FortranParser
 
   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..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 a414f226058e3e..89491fd2fa2a71 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 08041f93b14b6c..e2440ad6fbc427 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 58820476c51bc1..9e3026e1fa8dbb 100644
--- a/flang/lib/Parser/unparse.cpp
+++ b/flang/lib/Parser/unparse.cpp
@@ -10,13 +10,13 @@
 // traversal templates in parse-tree-visitor.h.
 
 #include "flang/Parser/unparse.h"
-#include "flang/Common/Fortran.h"
 #include "flang/Common/idioms.h"
-#include "flang/Common/indirection.h"
 #include "flang/Parser/characters.h"
 #include "flang/Parser/parse-tree-visitor.h"
 #include "flang/Parser/parse-tree.h"
 #include "flang/Parser/tools.h"
+#include "flang/Support/Fortran.h"
+#include "flang/Support/indirection.h"
 #include "llvm/Support/raw_ostream.h"
 #include <algorithm>
 #include <cinttypes>
diff --git a/flang/lib/Semantics/CMakeLists.txt b/flang/lib/Semantics/CMakeLists.txt
index 7855ae7eed1387..9027dd9e72460c 100644
--- a/flang/lib/Semantics/CMakeLists.txt
+++ b/flang/lib/Semantics/CMakeLists.txt
@@ -54,6 +54,7 @@ add_flang_library(FortranSemantics
 
   LINK_LIBS
   FortranCommon
+  FortranSupport
   FortranParser
   FortranEvaluate
 
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 5ce143c9aec91a..c81d3b16ab313c 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 d8a5639227648f..d079f5b6aa5301 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 84e6b6455cc612..ddba4c04b1ee3f 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 22729f659ed5be..52220a566bbdcc 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 c2eb17c1ac8e5b..4e45521687af9e 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 2450ce39215ec9..2698d26aeaef41 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 04e4b142efedf8..584319b8abdf63 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 a838d49c06104d..065090ed03b6a6 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 122c0a2ebb646a..2b8ee8928faefc 100644
--- a/flang/lib/Semantics/resolve-names.cpp
+++ b/flang/lib/Semantics/resolve-names.cpp
@@ -13,9 +13,6 @@
 #include "resolve-directives.h"
 #include "resolve-names-utils.h"
 #include "rewrite-parse-tree.h"
-#include "flang/Common/Fortran.h"
-#include "flang/Common/default-kinds.h"
-#include "flang/Common/indirection.h"
 #include "flang/Common/restorer.h"
 #include "flang/Common/visit.h"
 #include "flang/Evaluate/characteristics.h"
@@ -38,6 +35,9 @@
 #include "flang/Semantics/symbol.h"
 #include "flang/Semantics/tools.h"
 #include "flang/Semantics/type.h"
+#include "flang/Support/Fortran.h"
+#include "flang/Support/default-kinds.h"
+#include "flang/Support/indirection.h"
 #include "llvm/Support/raw_ostream.h"
 #include <list>
 #include <map>
diff --git a/flang/lib/Semantics/rewrite-parse-tree.cpp b/flang/lib/Semantics/rewrite-parse-tree.cpp
index 577558e7e33b26..171c0021fba08c 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 58dc1f218b56f4..10a01039ea0ae7 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 9e180605c1b3bd..7a3b93f10a3e77 100644
--- a/flang/lib/Semantics/tools.cpp
+++ b/flang/lib/Semantics/tools.cpp
@@ -7,8 +7,6 @@
 //===----------------------------------------------------------------------===//
 
 #include "flang/Parser/tools.h"
-#include "flang/Common/Fortran.h"
-#include "flang/Common/indirection.h"
 #include "flang/Parser/dump-parse-tree.h"
 #include "flang/Parser/message.h"
 #include "flang/Parser/parse-tree.h"
@@ -17,6 +15,8 @@
 #include "flang/Semantics/symbol.h"
 #include "flang/Semantics/tools.h"
 #include "flang/Semantics/type.h"
+#include "flang/Support/Fortran.h"
+#include "flang/Support/indirection.h"
 #include "llvm/Support/raw_ostream.h"
 #include <algorithm>
 #include <set>
diff --git a/flang/lib/Support/CMakeLists.txt b/flang/lib/Support/CMakeLists.txt
new file mode 100644
index 00000000000000..a2badde61dfe64
--- /dev/null
+++ b/flang/lib/Support/CMakeLists.txt
@@ -0,0 +1,61 @@
+#===-- lib/Support/CMakeLists.txt ------------------------------------------===#
+#
+# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+# See https://llvm.org/LICENSE.txt for license information.
+# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+#
+#===------------------------------------------------------------------------===#
+
+find_first_existing_vc_file("${LLVM_MAIN_SRC_DIR}" llvm_vc)
+find_first_existing_vc_file("${FLANG_SOURCE_DIR}" flang_vc)
+
+# The VC revision include that we want to generate.
+set(version_inc "${CMAKE_CURRENT_BINARY_DIR}/VCSVersion.inc")
+
+set(generate_vcs_version_script "${LLVM_CMAKE_DIR}/GenerateVersionFromVCS.cmake")
+
+if(llvm_vc AND LLVM_APPEND_VC_REV)
+  set(llvm_source_dir ${LLVM_MAIN_SRC_DIR})
+endif()
+if(flang_vc AND LLVM_APPEND_VC_REV)
+  set(flang_source_dir ${FLANG_SOURCE_DIR})
+endif()
+
+# Create custom target to generate the VC revision include.
+add_custom_command(OUTPUT "${version_inc}"
+  DEPENDS "${llvm_vc}" "${flang_vc}" "${generate_vcs_version_script}"
+  COMMAND ${CMAKE_COMMAND} "-DNAMES=\"LLVM;FLANG\""
+                           "-DLLVM_SOURCE_DIR=${llvm_source_dir}"
+                           "-DFLANG_SOURCE_DIR=${flang_source_dir}"
+                           "-DHEADER_FILE=${version_inc}"
+                           "-DLLVM_FORCE_VC_REVISION=${LLVM_FORCE_VC_REVISION}"
+                           "-DLLVM_FORCE_VC_REPOSITORY=${LLVM_FORCE_VC_REPOSITORY}"
+                           -P "${generate_vcs_version_script}")
+
+# Mark the generated header as being generated.
+set_source_files_properties("${version_inc}"
+  PROPERTIES GENERATED TRUE
+             HEADER_FILE_ONLY TRUE)
+
+if(FLANG_VENDOR)
+  set_source_files_properties(Version.cpp
+    PROPERTIES COMPILE_DEFINITIONS "FLANG_VENDOR=\"${FLANG_VENDOR} \"")
+endif()
+
+
+add_flang_library(FortranSupport
+  Fortran.cpp
+  Fortran-features.cpp
+  default-kinds.cpp
+  idioms.cpp
+  LangOptions.cpp
+  OpenMP-utils.cpp
+  Version.cpp
+  ${version_inc}
+
+  LINK_COMPONENTS
+    Support
+
+  LINK_LIBS
+    MLIRIR
+)
diff --git a/flang/lib/Common/Fortran-features.cpp b/flang/lib/Support/Fortran-features.cpp
similarity index 97%
rename from flang/lib/Common/Fortran-features.cpp
rename to flang/lib/Support/Fortran-features.cpp
index 3565275915a312..be84072ae6a5b1 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 367a51f884e8a5..09c0d96115d4df 100644
--- a/flang/lib/Common/Fortran.cpp
+++ b/flang/lib/Support/Fortran.cpp
@@ -1,4 +1,4 @@
-//===-- lib/Common/Fortran.cpp --------------------------------------------===//
+//===-- lib/Support/Fortran.cpp ---------------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -6,8 +6,8 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "flang/Common/Fortran.h"
-#include "flang/Common/Fortran-features.h"
+#include "flang/Support/Fortran.h"
+#include "flang/Support/Fortran-features.h"
 
 namespace Fortran::common {
 
diff --git a/flang/lib/Common/LangOptions.cpp b/flang/lib/Support/LangOptions.cpp
similarity index 80%
rename from flang/lib/Common/LangOptions.cpp
rename to flang/lib/Support/LangOptions.cpp
index 415c715156e7bf..273274fc07215d 100644
--- a/flang/lib/Common/LangOptions.cpp
+++ b/flang/lib/Support/LangOptions.cpp
@@ -1,4 +1,4 @@
-//===------ LangOptions.cpp -----------------------------------------------===//
+//===-- lib/Support/LangOptions.cpp -----------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -10,7 +10,7 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "flang/Common/LangOptions.h"
+#include "flang/Support/LangOptions.h"
 #include <string.h>
 
 namespace Fortran::common {
@@ -18,7 +18,7 @@ namespace Fortran::common {
 LangOptions::LangOptions() {
 #define LANGOPT(Name, Bits, Default) Name = Default;
 #define ENUM_LANGOPT(Name, Type, Bits, Default) set##Name(Default);
-#include "flang/Common/LangOptions.def"
+#include "flang/Support/LangOptions.def"
 }
 
 } // end namespace Fortran::common
diff --git a/flang/lib/Common/OpenMP-utils.cpp b/flang/lib/Support/OpenMP-utils.cpp
similarity index 95%
rename from flang/lib/Common/OpenMP-utils.cpp
rename to flang/lib/Support/OpenMP-utils.cpp
index f5115f475d6a19..5164de9acb4fb0 100644
--- a/flang/lib/Common/OpenMP-utils.cpp
+++ b/flang/lib/Support/OpenMP-utils.cpp
@@ -1,4 +1,4 @@
-//===-- include/flang/Common/OpenMP-utils.cpp ------------------*- C++ -*-====//
+//===-- lib/Support/OpenMP-utils.cpp ----------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/lib/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 fbafd827ff0d0b..c6d7759097be17 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/CUDA/allocator.cpp b/flang/runtime/CUDA/allocator.cpp
index 85b3daf65a8ba4..85db479c024540 100644
--- a/flang/runtime/CUDA/allocator.cpp
+++ b/flang/runtime/CUDA/allocator.cpp
@@ -12,7 +12,7 @@
 #include "../terminator.h"
 #include "../type-info.h"
 #include "flang/Common/Fortran.h"
-#include "flang/ISO_Fortran_binding_wrapper.h"
+#include "flang/Common/ISO_Fortran_binding_wrapper.h"
 #include "flang/Runtime/CUDA/common.h"
 #include "flang/Runtime/allocator-registry.h"
 
diff --git a/flang/runtime/ISO_Fortran_binding.cpp b/flang/runtime/ISO_Fortran_binding.cpp
index fe22026f31f55f..64e239f498230c 100644
--- a/flang/runtime/ISO_Fortran_binding.cpp
+++ b/flang/runtime/ISO_Fortran_binding.cpp
@@ -11,7 +11,7 @@
 
 #include "ISO_Fortran_util.h"
 #include "terminator.h"
-#include "flang/ISO_Fortran_binding_wrapper.h"
+#include "flang/Common/ISO_Fortran_binding_wrapper.h"
 #include "flang/Runtime/descriptor.h"
 #include "flang/Runtime/pointer.h"
 #include "flang/Runtime/type-code.h"
diff --git a/flang/runtime/ISO_Fortran_util.h b/flang/runtime/ISO_Fortran_util.h
index dd0eeef80bb896..aca9aee8c5718e 100644
--- a/flang/runtime/ISO_Fortran_util.h
+++ b/flang/runtime/ISO_Fortran_util.h
@@ -12,7 +12,7 @@
 // Internal utils for establishing CFI_cdesc_t descriptors.
 
 #include "terminator.h"
-#include "flang/ISO_Fortran_binding_wrapper.h"
+#include "flang/Common/ISO_Fortran_binding_wrapper.h"
 #include "flang/Runtime/descriptor.h"
 #include "flang/Runtime/type-code.h"
 #include <cstdlib>
diff --git a/flang/runtime/allocatable.cpp b/flang/runtime/allocatable.cpp
index 5e065f47636a89..686114bf86eafa 100644
--- a/flang/runtime/allocatable.cpp
+++ b/flang/runtime/allocatable.cpp
@@ -12,7 +12,7 @@
 #include "stat.h"
 #include "terminator.h"
 #include "type-info.h"
-#include "flang/ISO_Fortran_binding_wrapper.h"
+#include "flang/Common/ISO_Fortran_binding_wrapper.h"
 #include "flang/Runtime/assign.h"
 #include "flang/Runtime/descriptor.h"
 
diff --git a/flang/runtime/edit-output.h b/flang/runtime/edit-output.h
index 578c7c762f2e36..6ae49265b64df5 100644
--- a/flang/runtime/edit-output.h
+++ b/flang/runtime/edit-output.h
@@ -20,8 +20,8 @@
 
 #include "format.h"
 #include "io-stmt.h"
-#include "flang/Common/uint128.h"
 #include "flang/Common/decimal.h"
+#include "flang/Common/uint128.h"
 
 namespace Fortran::runtime::io {
 
diff --git a/flang/runtime/environment.h b/flang/runtime/environment.h
index dfa8c14dd64081..90aa1e8dd28d77 100644
--- a/flang/runtime/environment.h
+++ b/flang/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;
 
diff --git a/flang/runtime/format-implementation.h b/flang/runtime/format-implementation.h
index 783463ace8b27f..1dd526ce897aea 100644
--- a/flang/runtime/format-implementation.h
+++ b/flang/runtime/format-implementation.h
@@ -15,8 +15,8 @@
 #include "format.h"
 #include "io-stmt.h"
 #include "memory.h"
-#include "flang/Common/format.h"
 #include "flang/Common/decimal.h"
+#include "flang/Common/format.h"
 #include "flang/Runtime/main.h"
 #include <algorithm>
 #include <cstring>
diff --git a/flang/runtime/format.h b/flang/runtime/format.h
index 25aa8e9961e74a..8362c7233b688f 100644
--- a/flang/runtime/format.h
+++ b/flang/runtime/format.h
@@ -14,8 +14,8 @@
 #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 <cinttypes>
 
diff --git a/flang/runtime/stat.h b/flang/runtime/stat.h
index 71faeb027d9085..572cb6d10b4893 100644
--- a/flang/runtime/stat.h
+++ b/flang/runtime/stat.h
@@ -11,8 +11,8 @@
 
 #ifndef FORTRAN_RUNTIME_STAT_H_
 #define FORTRAN_RUNTIME_STAT_H_
+#include "flang/Common/ISO_Fortran_binding_wrapper.h"
 #include "flang/Common/api-attrs.h"
-#include "flang/ISO_Fortran_binding_wrapper.h"
 #include "flang/Runtime/magic-numbers.h"
 namespace Fortran::runtime {
 
diff --git a/flang/runtime/temporary-stack.cpp b/flang/runtime/temporary-stack.cpp
index 667b10e04dbd29..93340266b1b44d 100644
--- a/flang/runtime/temporary-stack.cpp
+++ b/flang/runtime/temporary-stack.cpp
@@ -11,7 +11,7 @@
 
 #include "flang/Runtime/temporary-stack.h"
 #include "terminator.h"
-#include "flang/ISO_Fortran_binding_wrapper.h"
+#include "flang/Common/ISO_Fortran_binding_wrapper.h"
 #include "flang/Runtime/assign.h"
 #include "flang/Runtime/descriptor.h"
 #include "flang/Runtime/memory.h"
diff --git a/flang/tools/bbc/CMakeLists.txt b/flang/tools/bbc/CMakeLists.txt
index 9abdcf17b6ebfd..a608d472fd997b 100644
--- a/flang/tools/bbc/CMakeLists.txt
+++ b/flang/tools/bbc/CMakeLists.txt
@@ -33,6 +33,7 @@ target_link_libraries(bbc PRIVATE
   MLIRAffineToStandard
   MLIRSCFToControlFlow
   FortranCommon
+  FortranSupport
   FortranParser
   FortranEvaluate
   FortranSemantics
diff --git a/flang/tools/bbc/bbc.cpp b/flang/tools/bbc/bbc.cpp
index 7efc460be86795..4499e44711bd35 100644
--- a/flang/tools/bbc/bbc.cpp
+++ b/flang/tools/bbc/bbc.cpp
@@ -14,11 +14,6 @@
 ///
 //===----------------------------------------------------------------------===//
 
-#include "flang/Common/Fortran-features.h"
-#include "flang/Common/LangOptions.h"
-#include "flang/Common/OpenMP-features.h"
-#include "flang/Common/Version.h"
-#include "flang/Common/default-kinds.h"
 #include "flang/Frontend/CodeGenOptions.h"
 #include "flang/Frontend/TargetOptions.h"
 #include "flang/Lower/Bridge.h"
@@ -42,6 +37,11 @@
 #include "flang/Semantics/runtime-type-info.h"
 #include "flang/Semantics/semantics.h"
 #include "flang/Semantics/unparse-with-symbols.h"
+#include "flang/Support/Fortran-features.h"
+#include "flang/Support/LangOptions.h"
+#include "flang/Support/OpenMP-features.h"
+#include "flang/Support/Version.h"
+#include "flang/Support/default-kinds.h"
 #include "flang/Tools/CrossToolHelpers.h"
 #include "flang/Tools/TargetSetup.h"
 #include "flang/Version.inc"
diff --git a/flang/tools/f18-parse-demo/f18-parse-demo.cpp b/flang/tools/f18-parse-demo/f18-parse-demo.cpp
index 3025dbd4dca4ab..90bbce246e3f16 100644
--- a/flang/tools/f18-parse-demo/f18-parse-demo.cpp
+++ b/flang/tools/f18-parse-demo/f18-parse-demo.cpp
@@ -21,8 +21,7 @@
 // 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/Parser/characters.h"
 #include "flang/Parser/dump-parse-tree.h"
 #include "flang/Parser/message.h"
@@ -31,6 +30,7 @@
 #include "flang/Parser/parsing.h"
 #include "flang/Parser/provenance.h"
 #include "flang/Parser/unparse.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/ISO-Fortran-binding.cpp b/flang/unittests/Evaluate/ISO-Fortran-binding.cpp
index 3c98363f900466..38688b404876ff 100644
--- a/flang/unittests/Evaluate/ISO-Fortran-binding.cpp
+++ b/flang/unittests/Evaluate/ISO-Fortran-binding.cpp
@@ -1,5 +1,5 @@
 #include "testing.h"
-#include "flang/ISO_Fortran_binding_wrapper.h"
+#include "flang/Common/ISO_Fortran_binding_wrapper.h"
 #include "flang/Runtime/descriptor.h"
 #include "llvm/Support/raw_ostream.h"
 #include <type_traits>
diff --git a/flang/unittests/Runtime/TemporaryStack.cpp b/flang/unittests/Runtime/TemporaryStack.cpp
index 0a9344969ca6ba..4f701e09b29452 100644
--- a/flang/unittests/Runtime/TemporaryStack.cpp
+++ b/flang/unittests/Runtime/TemporaryStack.cpp
@@ -8,7 +8,7 @@
 
 #include "gtest/gtest.h"
 #include "tools.h"
-#include "flang/ISO_Fortran_binding_wrapper.h"
+#include "flang/Common/ISO_Fortran_binding_wrapper.h"
 #include "flang/Runtime/allocatable.h"
 #include "flang/Runtime/cpp-type.h"
 #include "flang/Runtime/descriptor.h"

>From 10795909d14d581fdacab9e95b4107c4fe768241 Mon Sep 17 00:00:00 2001
From: Michael Kruse <llvm-project at meinersbur.de>
Date: Wed, 8 Jan 2025 15:17:17 +0100
Subject: [PATCH 2/9] clang-format headers

---
 flang/lib/Evaluate/real.cpp             | 2 +-
 flang/runtime/edit-output.h             | 2 +-
 flang/runtime/environment.h             | 2 +-
 flang/runtime/format-implementation.h   | 2 +-
 flang/runtime/format.h                  | 2 +-
 flang/test/CMakeLists.txt               | 1 +
 flang/unittests/Evaluate/CMakeLists.txt | 1 +
 7 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/flang/lib/Evaluate/real.cpp b/flang/lib/Evaluate/real.cpp
index af6df14f119c53..4c78a0ab658e0e 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/runtime/edit-output.h b/flang/runtime/edit-output.h
index 578c7c762f2e36..6ae49265b64df5 100644
--- a/flang/runtime/edit-output.h
+++ b/flang/runtime/edit-output.h
@@ -20,8 +20,8 @@
 
 #include "format.h"
 #include "io-stmt.h"
-#include "flang/Common/uint128.h"
 #include "flang/Common/decimal.h"
+#include "flang/Common/uint128.h"
 
 namespace Fortran::runtime::io {
 
diff --git a/flang/runtime/environment.h b/flang/runtime/environment.h
index dfa8c14dd64081..90aa1e8dd28d77 100644
--- a/flang/runtime/environment.h
+++ b/flang/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;
 
diff --git a/flang/runtime/format-implementation.h b/flang/runtime/format-implementation.h
index 783463ace8b27f..1dd526ce897aea 100644
--- a/flang/runtime/format-implementation.h
+++ b/flang/runtime/format-implementation.h
@@ -15,8 +15,8 @@
 #include "format.h"
 #include "io-stmt.h"
 #include "memory.h"
-#include "flang/Common/format.h"
 #include "flang/Common/decimal.h"
+#include "flang/Common/format.h"
 #include "flang/Runtime/main.h"
 #include <algorithm>
 #include <cstring>
diff --git a/flang/runtime/format.h b/flang/runtime/format.h
index 25aa8e9961e74a..8362c7233b688f 100644
--- a/flang/runtime/format.h
+++ b/flang/runtime/format.h
@@ -14,8 +14,8 @@
 #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 <cinttypes>
 
diff --git a/flang/test/CMakeLists.txt b/flang/test/CMakeLists.txt
index e38c9b50259376..1ac7253832f6b8 100644
--- a/flang/test/CMakeLists.txt
+++ b/flang/test/CMakeLists.txt
@@ -72,6 +72,7 @@ set(FLANG_TEST_DEPENDS
   llvm-readobj
   split-file
   FortranRuntime
+  FortranCommon
 )
 if (LLVM_ENABLE_PLUGINS AND NOT WIN32)
   list(APPEND FLANG_TEST_DEPENDS Bye)
diff --git a/flang/unittests/Evaluate/CMakeLists.txt b/flang/unittests/Evaluate/CMakeLists.txt
index c008304c095575..210a397e46b675 100644
--- a/flang/unittests/Evaluate/CMakeLists.txt
+++ b/flang/unittests/Evaluate/CMakeLists.txt
@@ -63,6 +63,7 @@ set(LLVM_REQUIRES_RTTI ON)
 add_flang_nongtest_unittest(real
   FortranEvaluateTesting
   FortranEvaluate
+  FortranCommon
   FortranSemantics
 )
 llvm_update_compile_flags(real.test)

>From 5d73279dc3f501008112c471825345a23ea629d3 Mon Sep 17 00:00:00 2001
From: Michael Kruse <llvm-project at meinersbur.de>
Date: Wed, 8 Jan 2025 11:23:02 +0100
Subject: [PATCH 3/9] clang-format to sort headers

---
 flang/tools/f18-parse-demo/f18-parse-demo.cpp | 2 +-
 flang/unittests/Evaluate/CMakeLists.txt       | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/flang/tools/f18-parse-demo/f18-parse-demo.cpp b/flang/tools/f18-parse-demo/f18-parse-demo.cpp
index 90bbce246e3f16..a50c88dc840643 100644
--- a/flang/tools/f18-parse-demo/f18-parse-demo.cpp
+++ b/flang/tools/f18-parse-demo/f18-parse-demo.cpp
@@ -21,7 +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/Parser/characters.h"
 #include "flang/Parser/dump-parse-tree.h"
 #include "flang/Parser/message.h"
@@ -30,6 +29,7 @@
 #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"
diff --git a/flang/unittests/Evaluate/CMakeLists.txt b/flang/unittests/Evaluate/CMakeLists.txt
index c008304c095575..210a397e46b675 100644
--- a/flang/unittests/Evaluate/CMakeLists.txt
+++ b/flang/unittests/Evaluate/CMakeLists.txt
@@ -63,6 +63,7 @@ set(LLVM_REQUIRES_RTTI ON)
 add_flang_nongtest_unittest(real
   FortranEvaluateTesting
   FortranEvaluate
+  FortranCommon
   FortranSemantics
 )
 llvm_update_compile_flags(real.test)

>From 3a11ec48ac1306af35c0816f15f15eabcaa1c947 Mon Sep 17 00:00:00 2001
From: Michael Kruse <llvm-project at meinersbur.de>
Date: Wed, 8 Jan 2025 16:09:26 +0100
Subject: [PATCH 4/9] Link fix

---
 flang/test/CMakeLists.txt                 | 1 -
 flang/tools/f18-parse-demo/CMakeLists.txt | 1 +
 flang/tools/tco/CMakeLists.txt            | 1 +
 flang/unittests/Evaluate/CMakeLists.txt   | 4 ++++
 flang/unittests/Frontend/CMakeLists.txt   | 1 +
 5 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/flang/test/CMakeLists.txt b/flang/test/CMakeLists.txt
index 1ac7253832f6b8..e38c9b50259376 100644
--- a/flang/test/CMakeLists.txt
+++ b/flang/test/CMakeLists.txt
@@ -72,7 +72,6 @@ set(FLANG_TEST_DEPENDS
   llvm-readobj
   split-file
   FortranRuntime
-  FortranCommon
 )
 if (LLVM_ENABLE_PLUGINS AND NOT WIN32)
   list(APPEND FLANG_TEST_DEPENDS Bye)
diff --git a/flang/tools/f18-parse-demo/CMakeLists.txt b/flang/tools/f18-parse-demo/CMakeLists.txt
index df1f1d24a55e51..800b29fcf4251f 100644
--- a/flang/tools/f18-parse-demo/CMakeLists.txt
+++ b/flang/tools/f18-parse-demo/CMakeLists.txt
@@ -12,5 +12,6 @@ add_flang_tool(f18-parse-demo
 target_link_libraries(f18-parse-demo
   PRIVATE
   FortranCommon
+  FortranSupport
   FortranParser
   )
diff --git a/flang/tools/tco/CMakeLists.txt b/flang/tools/tco/CMakeLists.txt
index aac80437ee11d9..4d05ba5d1f907f 100644
--- a/flang/tools/tco/CMakeLists.txt
+++ b/flang/tools/tco/CMakeLists.txt
@@ -20,6 +20,7 @@ target_link_libraries(tco PRIVATE
   flangPasses
   FlangOpenMPTransforms
   FortranCommon
+  FortranSupport
   ${dialect_libs}
   ${extension_libs}
   MLIRIR
diff --git a/flang/unittests/Evaluate/CMakeLists.txt b/flang/unittests/Evaluate/CMakeLists.txt
index 210a397e46b675..acdd3ffa1c7337 100644
--- a/flang/unittests/Evaluate/CMakeLists.txt
+++ b/flang/unittests/Evaluate/CMakeLists.txt
@@ -27,6 +27,7 @@ add_flang_nongtest_unittest(uint128
 
 add_flang_nongtest_unittest(expression
   FortranCommon
+  FortranSupport
   FortranEvaluateTesting
   FortranEvaluate
   FortranSemantics
@@ -41,6 +42,7 @@ add_flang_nongtest_unittest(integer
 
 add_flang_nongtest_unittest(intrinsics
   FortranCommon
+  FortranSupport
   FortranEvaluateTesting
   FortranEvaluate
   FortranSemantics
@@ -64,6 +66,7 @@ add_flang_nongtest_unittest(real
   FortranEvaluateTesting
   FortranEvaluate
   FortranCommon
+  FortranSupport
   FortranSemantics
 )
 llvm_update_compile_flags(real.test)
@@ -84,6 +87,7 @@ add_flang_nongtest_unittest(ISO-Fortran-binding
 
 add_flang_nongtest_unittest(folding
   FortranCommon
+  FortranSupport
   FortranEvaluateTesting
   FortranEvaluate
   FortranSemantics
diff --git a/flang/unittests/Frontend/CMakeLists.txt b/flang/unittests/Frontend/CMakeLists.txt
index 22c568af3d121a..a4a18e313c1f4f 100644
--- a/flang/unittests/Frontend/CMakeLists.txt
+++ b/flang/unittests/Frontend/CMakeLists.txt
@@ -19,6 +19,7 @@ target_link_libraries(FlangFrontendTests
   FortranParser
   FortranSemantics
   FortranCommon
+  FortranSupport
   FortranEvaluate
   MLIRIR
 )

>From 308d180adaad8acbddc3d8b05fd5312b7723020c Mon Sep 17 00:00:00 2001
From: Michael Kruse <llvm-project at meinersbur.de>
Date: Wed, 8 Jan 2025 16:26:30 +0100
Subject: [PATCH 5/9] Post-merge fixes

---
 flang/lib/Optimizer/Builder/IntrinsicCall.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/flang/lib/Optimizer/Builder/IntrinsicCall.cpp b/flang/lib/Optimizer/Builder/IntrinsicCall.cpp
index 9781e842a56aab..bcc1c7f4f003af 100644
--- a/flang/lib/Optimizer/Builder/IntrinsicCall.cpp
+++ b/flang/lib/Optimizer/Builder/IntrinsicCall.cpp
@@ -778,7 +778,7 @@ prettyPrintIntrinsicName(fir::FirOpBuilder &builder, mlir::Location loc,
 // Generate a call to the Fortran runtime library providing
 // support for 128-bit float math.
 // On 'HAS_LDBL128' targets the implementation
-// is provided by flang_rt, otherwise, it is done via
+// is provided by FortranRuntime, otherwise, it is done via
 // FortranFloat128Math library. In the latter case the compiler
 // has to be built with FLANG_RUNTIME_F128_MATH_LIB to guarantee
 // proper linking actions in the driver.

>From 7f342b79b8beb187744d1d04674b884baca6e8cc Mon Sep 17 00:00:00 2001
From: Michael Kruse <llvm-project at meinersbur.de>
Date: Wed, 8 Jan 2025 18:22:09 +0100
Subject: [PATCH 6/9] Fix headers

---
 flang/runtime/CUDA/allocatable.cpp            | 1 +
 flang/runtime/CUDA/allocator.cpp              | 2 +-
 flang/unittests/Runtime/CUDA/Allocatable.cpp  | 4 +++-
 flang/unittests/Runtime/CUDA/AllocatorCUF.cpp | 4 +++-
 flang/unittests/Runtime/CUDA/Memory.cpp       | 2 +-
 5 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/flang/runtime/CUDA/allocatable.cpp b/flang/runtime/CUDA/allocatable.cpp
index 9be54e8906903d..e99cd40bbb07f8 100644
--- a/flang/runtime/CUDA/allocatable.cpp
+++ b/flang/runtime/CUDA/allocatable.cpp
@@ -14,6 +14,7 @@
 #include "flang/Runtime/CUDA/descriptor.h"
 #include "flang/Runtime/CUDA/memmove-function.h"
 #include "flang/Runtime/allocatable.h"
+#include "flang/Runtime/descriptor.h"
 
 #include "cuda_runtime.h"
 
diff --git a/flang/runtime/CUDA/allocator.cpp b/flang/runtime/CUDA/allocator.cpp
index 85db479c024540..368c1124ef70a5 100644
--- a/flang/runtime/CUDA/allocator.cpp
+++ b/flang/runtime/CUDA/allocator.cpp
@@ -11,10 +11,10 @@
 #include "../stat.h"
 #include "../terminator.h"
 #include "../type-info.h"
-#include "flang/Common/Fortran.h"
 #include "flang/Common/ISO_Fortran_binding_wrapper.h"
 #include "flang/Runtime/CUDA/common.h"
 #include "flang/Runtime/allocator-registry.h"
+#include "flang/Support/Fortran.h"
 
 #include "cuda_runtime.h"
 
diff --git a/flang/unittests/Runtime/CUDA/Allocatable.cpp b/flang/unittests/Runtime/CUDA/Allocatable.cpp
index 0f7eb27789316c..ddbcc3a1c9eefb 100644
--- a/flang/unittests/Runtime/CUDA/Allocatable.cpp
+++ b/flang/unittests/Runtime/CUDA/Allocatable.cpp
@@ -9,11 +9,13 @@
 #include "flang/Runtime/allocatable.h"
 #include "gtest/gtest.h"
 #include "../../../runtime/terminator.h"
-#include "flang/Common/Fortran.h"
 #include "flang/Runtime/CUDA/allocator.h"
 #include "flang/Runtime/CUDA/common.h"
 #include "flang/Runtime/CUDA/descriptor.h"
 #include "flang/Runtime/allocator-registry.h"
+#include "flang/Runtime/descriptor.h"
+#include "flang/Runtime/memory.h"
+#include "flang/Support/Fortran.h"
 
 #include "cuda_runtime.h"
 
diff --git a/flang/unittests/Runtime/CUDA/AllocatorCUF.cpp b/flang/unittests/Runtime/CUDA/AllocatorCUF.cpp
index 7cb25787e7797b..68b74fab0c58dc 100644
--- a/flang/unittests/Runtime/CUDA/AllocatorCUF.cpp
+++ b/flang/unittests/Runtime/CUDA/AllocatorCUF.cpp
@@ -8,11 +8,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/Runtime/descriptor.h"
+#include "flang/Runtime/memory.h"
+#include "flang/Support/Fortran.h"
 
 #include "cuda_runtime.h"
 
diff --git a/flang/unittests/Runtime/CUDA/Memory.cpp b/flang/unittests/Runtime/CUDA/Memory.cpp
index 7c8b7aa5a4d78b..61c9d1131ee567 100644
--- a/flang/unittests/Runtime/CUDA/Memory.cpp
+++ b/flang/unittests/Runtime/CUDA/Memory.cpp
@@ -10,12 +10,12 @@
 #include "gtest/gtest.h"
 #include "../../../runtime/terminator.h"
 #include "../tools.h"
-#include "flang/Common/Fortran.h"
 #include "flang/Runtime/CUDA/allocator.h"
 #include "flang/Runtime/CUDA/common.h"
 #include "flang/Runtime/CUDA/descriptor.h"
 #include "flang/Runtime/allocatable.h"
 #include "flang/Runtime/allocator-registry.h"
+#include "flang/Support/Fortran.h"
 
 #include "cuda_runtime.h"
 

>From baa7cb19d7f77c4be9c283d1662ec6b5d4d0646f Mon Sep 17 00:00:00 2001
From: Michael Kruse <llvm-project at meinersbur.de>
Date: Thu, 9 Jan 2025 04:11:17 +0100
Subject: [PATCH 7/9] Post-merge fixes

---
 flang/lib/CMakeLists.txt                      |  1 -
 flang/lib/Common/CMakeLists.txt               | 10 ----------
 flang/lib/Evaluate/CMakeLists.txt             |  1 -
 flang/lib/Frontend/CMakeLists.txt             |  1 -
 flang/lib/Lower/CMakeLists.txt                |  1 -
 flang/lib/Optimizer/OpenMP/CMakeLists.txt     |  1 -
 flang/lib/Optimizer/Passes/CMakeLists.txt     |  1 -
 flang/lib/Optimizer/Transforms/CMakeLists.txt |  1 -
 flang/lib/Parser/CMakeLists.txt               |  1 -
 flang/lib/Semantics/CMakeLists.txt            |  1 -
 flang/tools/bbc/CMakeLists.txt                |  1 -
 flang/tools/f18-parse-demo/CMakeLists.txt     |  1 -
 flang/tools/tco/CMakeLists.txt                |  1 -
 flang/unittests/Evaluate/CMakeLists.txt       |  4 ----
 flang/unittests/Frontend/CMakeLists.txt       |  1 -
 15 files changed, 27 deletions(-)
 delete mode 100644 flang/lib/Common/CMakeLists.txt

diff --git a/flang/lib/CMakeLists.txt b/flang/lib/CMakeLists.txt
index 58545bf5a7b90c..ae34c8b5e9bc9e 100644
--- a/flang/lib/CMakeLists.txt
+++ b/flang/lib/CMakeLists.txt
@@ -1,4 +1,3 @@
-add_subdirectory(Common)
 add_subdirectory(Support)
 add_subdirectory(Evaluate)
 add_subdirectory(Decimal)
diff --git a/flang/lib/Common/CMakeLists.txt b/flang/lib/Common/CMakeLists.txt
deleted file mode 100644
index b8de84d869349c..00000000000000
--- a/flang/lib/Common/CMakeLists.txt
+++ /dev/null
@@ -1,10 +0,0 @@
-#===-- 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
-)
diff --git a/flang/lib/Evaluate/CMakeLists.txt b/flang/lib/Evaluate/CMakeLists.txt
index ecac4bab25bb32..e0bdb6b2d24d82 100644
--- a/flang/lib/Evaluate/CMakeLists.txt
+++ b/flang/lib/Evaluate/CMakeLists.txt
@@ -60,7 +60,6 @@ add_flang_library(FortranEvaluate
   variable.cpp
 
   LINK_LIBS
-  FortranCommon
   FortranSupport
   FortranDecimal
   FortranParser
diff --git a/flang/lib/Frontend/CMakeLists.txt b/flang/lib/Frontend/CMakeLists.txt
index 7078c911660bdb..acbed3a4b0cdc6 100644
--- a/flang/lib/Frontend/CMakeLists.txt
+++ b/flang/lib/Frontend/CMakeLists.txt
@@ -27,7 +27,6 @@ add_flang_library(flangFrontend
   FortranParser
   FortranSemantics
   FortranEvaluate
-  FortranCommon
   FortranSupport
   FortranLower
   FIRDialect
diff --git a/flang/lib/Lower/CMakeLists.txt b/flang/lib/Lower/CMakeLists.txt
index 7885c96f4b6273..cb37857ab1de0b 100644
--- a/flang/lib/Lower/CMakeLists.txt
+++ b/flang/lib/Lower/CMakeLists.txt
@@ -56,7 +56,6 @@ add_flang_library(FortranLower
   HLFIRDialect
   ${dialect_libs}
   ${extension_libs}
-  FortranCommon
   FortranSupport
   FortranParser
   FortranEvaluate
diff --git a/flang/lib/Optimizer/OpenMP/CMakeLists.txt b/flang/lib/Optimizer/OpenMP/CMakeLists.txt
index a54062fecff50a..74b7bd3e4fb1cf 100644
--- a/flang/lib/Optimizer/OpenMP/CMakeLists.txt
+++ b/flang/lib/Optimizer/OpenMP/CMakeLists.txt
@@ -21,7 +21,6 @@ add_flang_library(FlangOpenMPTransforms
   FIRDialect
   FIRDialectSupport
   FIRSupport
-  FortranCommon
   FortranSupport
   FortranEvaluate
   MLIRFuncDialect
diff --git a/flang/lib/Optimizer/Passes/CMakeLists.txt b/flang/lib/Optimizer/Passes/CMakeLists.txt
index 029588dc7f7bbe..393e64e4240c88 100644
--- a/flang/lib/Optimizer/Passes/CMakeLists.txt
+++ b/flang/lib/Optimizer/Passes/CMakeLists.txt
@@ -11,7 +11,6 @@ add_flang_library(flangPasses
   FlangOpenMPTransforms
   ${dialect_libs}
   ${extension_libs}
-  FortranCommon
   FortranSupport
   HLFIRTransforms
   MLIRPass
diff --git a/flang/lib/Optimizer/Transforms/CMakeLists.txt b/flang/lib/Optimizer/Transforms/CMakeLists.txt
index 66c0a6dab1f2d2..713fcb49c585f8 100644
--- a/flang/lib/Optimizer/Transforms/CMakeLists.txt
+++ b/flang/lib/Optimizer/Transforms/CMakeLists.txt
@@ -46,7 +46,6 @@ add_flang_library(FIRTransforms
   FIRDialect
   FIRDialectSupport
   FIRSupport
-  FortranCommon
   FortranSupport
   HLFIRDialect
   MLIRAffineUtils
diff --git a/flang/lib/Parser/CMakeLists.txt b/flang/lib/Parser/CMakeLists.txt
index 96ee72a6e7a912..76fe3d7ce6ba48 100644
--- a/flang/lib/Parser/CMakeLists.txt
+++ b/flang/lib/Parser/CMakeLists.txt
@@ -25,7 +25,6 @@ add_flang_library(FortranParser
   user-state.cpp
 
   LINK_LIBS
-  FortranCommon
   FortranSupport
 
   LINK_COMPONENTS
diff --git a/flang/lib/Semantics/CMakeLists.txt b/flang/lib/Semantics/CMakeLists.txt
index 9027dd9e72460c..00108dde49dbdc 100644
--- a/flang/lib/Semantics/CMakeLists.txt
+++ b/flang/lib/Semantics/CMakeLists.txt
@@ -53,7 +53,6 @@ add_flang_library(FortranSemantics
   omp_gen
 
   LINK_LIBS
-  FortranCommon
   FortranSupport
   FortranParser
   FortranEvaluate
diff --git a/flang/tools/bbc/CMakeLists.txt b/flang/tools/bbc/CMakeLists.txt
index a608d472fd997b..3ffa5a49fb4962 100644
--- a/flang/tools/bbc/CMakeLists.txt
+++ b/flang/tools/bbc/CMakeLists.txt
@@ -32,7 +32,6 @@ target_link_libraries(bbc PRIVATE
   ${extension_libs}
   MLIRAffineToStandard
   MLIRSCFToControlFlow
-  FortranCommon
   FortranSupport
   FortranParser
   FortranEvaluate
diff --git a/flang/tools/f18-parse-demo/CMakeLists.txt b/flang/tools/f18-parse-demo/CMakeLists.txt
index 800b29fcf4251f..743a44017e8a5a 100644
--- a/flang/tools/f18-parse-demo/CMakeLists.txt
+++ b/flang/tools/f18-parse-demo/CMakeLists.txt
@@ -11,7 +11,6 @@ add_flang_tool(f18-parse-demo
 
 target_link_libraries(f18-parse-demo
   PRIVATE
-  FortranCommon
   FortranSupport
   FortranParser
   )
diff --git a/flang/tools/tco/CMakeLists.txt b/flang/tools/tco/CMakeLists.txt
index 4d05ba5d1f907f..aeb4a2e2c05db4 100644
--- a/flang/tools/tco/CMakeLists.txt
+++ b/flang/tools/tco/CMakeLists.txt
@@ -19,7 +19,6 @@ target_link_libraries(tco PRIVATE
   HLFIRTransforms
   flangPasses
   FlangOpenMPTransforms
-  FortranCommon
   FortranSupport
   ${dialect_libs}
   ${extension_libs}
diff --git a/flang/unittests/Evaluate/CMakeLists.txt b/flang/unittests/Evaluate/CMakeLists.txt
index efdda962b6da1e..0ea02ad7f71156 100644
--- a/flang/unittests/Evaluate/CMakeLists.txt
+++ b/flang/unittests/Evaluate/CMakeLists.txt
@@ -26,7 +26,6 @@ add_flang_nongtest_unittest(uint128
 )
 
 add_flang_nongtest_unittest(expression
-  FortranCommon
   FortranSupport
   FortranEvaluateTesting
   FortranEvaluate
@@ -41,7 +40,6 @@ add_flang_nongtest_unittest(integer
 )
 
 add_flang_nongtest_unittest(intrinsics
-  FortranCommon
   FortranSupport
   FortranEvaluateTesting
   FortranEvaluate
@@ -67,7 +65,6 @@ add_flang_nongtest_unittest(real
   FortranEvaluateTesting
   FortranEvaluate
   FortranDecimal
-  FortranSupport
   FortranSemantics
 )
 llvm_update_compile_flags(real.test)
@@ -87,7 +84,6 @@ add_flang_nongtest_unittest(ISO-Fortran-binding
 )
 
 add_flang_nongtest_unittest(folding
-  FortranCommon
   FortranSupport
   FortranEvaluateTesting
   FortranEvaluate
diff --git a/flang/unittests/Frontend/CMakeLists.txt b/flang/unittests/Frontend/CMakeLists.txt
index a4a18e313c1f4f..1616431ec1a7a6 100644
--- a/flang/unittests/Frontend/CMakeLists.txt
+++ b/flang/unittests/Frontend/CMakeLists.txt
@@ -18,7 +18,6 @@ target_link_libraries(FlangFrontendTests
   FortranLower
   FortranParser
   FortranSemantics
-  FortranCommon
   FortranSupport
   FortranEvaluate
   MLIRIR

>From 64b6b420048d1f48b203f0290693f3337f4ce8f5 Mon Sep 17 00:00:00 2001
From: Michael Kruse <llvm-project at meinersbur.de>
Date: Fri, 10 Jan 2025 14:14:31 +0100
Subject: [PATCH 8/9] Reduce change noise

---
 flang/include/flang/Runtime/allocatable.h     | 5 +----
 flang/include/flang/Runtime/io-api.h          | 2 +-
 flang/include/flang/Runtime/pointer.h         | 8 ++------
 flang/include/flang/Semantics/semantics.h     | 1 -
 flang/lib/Optimizer/Dialect/FIRType.cpp       | 2 +-
 flang/lib/Support/CMakeLists.txt              | 5 ++---
 flang/runtime/CUDA/allocatable.cpp            | 1 -
 flang/unittests/Runtime/CUDA/Allocatable.cpp  | 2 --
 flang/unittests/Runtime/CUDA/AllocatorCUF.cpp | 2 --
 9 files changed, 7 insertions(+), 21 deletions(-)

diff --git a/flang/include/flang/Runtime/allocatable.h b/flang/include/flang/Runtime/allocatable.h
index 480e987ed5ec6b..58061d9862095e 100644
--- a/flang/include/flang/Runtime/allocatable.h
+++ b/flang/include/flang/Runtime/allocatable.h
@@ -11,13 +11,10 @@
 #ifndef FORTRAN_RUNTIME_ALLOCATABLE_H_
 #define FORTRAN_RUNTIME_ALLOCATABLE_H_
 
-#include "flang/Common/Fortran-consts.h"
-#include "flang/Runtime/descriptor-consts.h"
+#include "flang/Runtime/descriptor.h"
 #include "flang/Runtime/entry-names.h"
 
 namespace Fortran::runtime {
-using SubscriptValue = ISO::CFI_index_t;
-using common::TypeCategory;
 
 extern "C" {
 
diff --git a/flang/include/flang/Runtime/io-api.h b/flang/include/flang/Runtime/io-api.h
index cee6b2cf033094..b86c3cecb32c5a 100644
--- a/flang/include/flang/Runtime/io-api.h
+++ b/flang/include/flang/Runtime/io-api.h
@@ -1,4 +1,4 @@
-//===-- include/flang-rt/io-api.h -------------------------------*- C++ -*-===//
+//===-- include/flang/Runtime/io-api.h --------------------------*- C++ -*-===//
 //
 // Part of the 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/pointer.h b/flang/include/flang/Runtime/pointer.h
index c6d29db7218376..704144f08114f2 100644
--- a/flang/include/flang/Runtime/pointer.h
+++ b/flang/include/flang/Runtime/pointer.h
@@ -12,14 +12,10 @@
 #ifndef FORTRAN_RUNTIME_POINTER_H_
 #define FORTRAN_RUNTIME_POINTER_H_
 
-#include "flang/Common/Fortran-consts.h"
-#include "flang/Runtime/descriptor-consts.h"
+#include "flang/Runtime/descriptor.h"
 #include "flang/Runtime/entry-names.h"
 
 namespace Fortran::runtime {
-using SubscriptValue = ISO::CFI_index_t;
-using common::TypeCategory;
-
 extern "C" {
 
 // Data pointer initialization for NULLIFY(), "p=>NULL()`, & for ALLOCATE().
@@ -126,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/Semantics/semantics.h b/flang/include/flang/Semantics/semantics.h
index 65ec1ce1eb6e33..c03a0bad24a6e9 100644
--- a/flang/include/flang/Semantics/semantics.h
+++ b/flang/include/flang/Semantics/semantics.h
@@ -17,7 +17,6 @@
 #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 "flang/Support/LangOptions.h"
 #include <iosfwd>
diff --git a/flang/lib/Optimizer/Dialect/FIRType.cpp b/flang/lib/Optimizer/Dialect/FIRType.cpp
index 8e5cf7f251501b..260966f82783a5 100644
--- a/flang/lib/Optimizer/Dialect/FIRType.cpp
+++ b/flang/lib/Optimizer/Dialect/FIRType.cpp
@@ -1419,4 +1419,4 @@ fir::getTypeSizeAndAlignmentOrCrash(mlir::Location loc, mlir::Type ty,
   if (result)
     return *result;
   TODO(loc, "computing size of a component");
-}
\ No newline at end of file
+}
diff --git a/flang/lib/Support/CMakeLists.txt b/flang/lib/Support/CMakeLists.txt
index a2badde61dfe64..8e0f0958952859 100644
--- a/flang/lib/Support/CMakeLists.txt
+++ b/flang/lib/Support/CMakeLists.txt
@@ -42,7 +42,6 @@ if(FLANG_VENDOR)
     PROPERTIES COMPILE_DEFINITIONS "FLANG_VENDOR=\"${FLANG_VENDOR} \"")
 endif()
 
-
 add_flang_library(FortranSupport
   Fortran.cpp
   Fortran-features.cpp
@@ -54,8 +53,8 @@ add_flang_library(FortranSupport
   ${version_inc}
 
   LINK_COMPONENTS
-    Support
+  Support
 
   LINK_LIBS
-    MLIRIR
+  MLIRIR
 )
diff --git a/flang/runtime/CUDA/allocatable.cpp b/flang/runtime/CUDA/allocatable.cpp
index e99cd40bbb07f8..9be54e8906903d 100644
--- a/flang/runtime/CUDA/allocatable.cpp
+++ b/flang/runtime/CUDA/allocatable.cpp
@@ -14,7 +14,6 @@
 #include "flang/Runtime/CUDA/descriptor.h"
 #include "flang/Runtime/CUDA/memmove-function.h"
 #include "flang/Runtime/allocatable.h"
-#include "flang/Runtime/descriptor.h"
 
 #include "cuda_runtime.h"
 
diff --git a/flang/unittests/Runtime/CUDA/Allocatable.cpp b/flang/unittests/Runtime/CUDA/Allocatable.cpp
index ddbcc3a1c9eefb..bdfa8f5cc3213c 100644
--- a/flang/unittests/Runtime/CUDA/Allocatable.cpp
+++ b/flang/unittests/Runtime/CUDA/Allocatable.cpp
@@ -13,8 +13,6 @@
 #include "flang/Runtime/CUDA/common.h"
 #include "flang/Runtime/CUDA/descriptor.h"
 #include "flang/Runtime/allocator-registry.h"
-#include "flang/Runtime/descriptor.h"
-#include "flang/Runtime/memory.h"
 #include "flang/Support/Fortran.h"
 
 #include "cuda_runtime.h"
diff --git a/flang/unittests/Runtime/CUDA/AllocatorCUF.cpp b/flang/unittests/Runtime/CUDA/AllocatorCUF.cpp
index 68b74fab0c58dc..5ec122e4c5777f 100644
--- a/flang/unittests/Runtime/CUDA/AllocatorCUF.cpp
+++ b/flang/unittests/Runtime/CUDA/AllocatorCUF.cpp
@@ -12,8 +12,6 @@
 #include "flang/Runtime/CUDA/descriptor.h"
 #include "flang/Runtime/allocatable.h"
 #include "flang/Runtime/allocator-registry.h"
-#include "flang/Runtime/descriptor.h"
-#include "flang/Runtime/memory.h"
 #include "flang/Support/Fortran.h"
 
 #include "cuda_runtime.h"

>From 32e5b84a57d734fe6403addd50424aaf4f876efa Mon Sep 17 00:00:00 2001
From: Michael Kruse <llvm-project at meinersbur.de>
Date: Mon, 20 Jan 2025 14:45:48 +0100
Subject: [PATCH 9/9] Post-merge fixes

---
 flang/include/flang/Support/Timing.h | 8 ++++----
 flang/lib/CMakeLists.txt             | 1 -
 flang/lib/Support/Timing.cpp         | 2 +-
 3 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/flang/include/flang/Support/Timing.h b/flang/include/flang/Support/Timing.h
index 75ba2a8d85f39f..5d66831d6c1c28 100644
--- a/flang/include/flang/Support/Timing.h
+++ b/flang/include/flang/Support/Timing.h
@@ -1,4 +1,4 @@
-//===- Timing.h - Execution time measurement facilities ---------*- C++ -*-===//
+//===-- include/flang/Support/Timing.h --------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -10,8 +10,8 @@
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef FORTRAN_SUPPORT_TIMING_H
-#define FORTRAN_SUPPORT_TIMING_H
+#ifndef FORTRAN_SUPPORT_TIMING_H_
+#define FORTRAN_SUPPORT_TIMING_H_
 
 #include "mlir/Support/Timing.h"
 
@@ -24,4 +24,4 @@ std::unique_ptr<mlir::OutputStrategy> createTimingFormatterText(
 
 } // namespace Fortran::support
 
-#endif // FORTRAN_SUPPORT_TIMING_H
+#endif /* FORTRAN_SUPPORT_TIMING_H_ */
diff --git a/flang/lib/CMakeLists.txt b/flang/lib/CMakeLists.txt
index 114af1b26791a4..05c3535b09b3d3 100644
--- a/flang/lib/CMakeLists.txt
+++ b/flang/lib/CMakeLists.txt
@@ -1,4 +1,3 @@
-add_subdirectory(Support)
 add_subdirectory(Evaluate)
 add_subdirectory(Decimal)
 add_subdirectory(Lower)
diff --git a/flang/lib/Support/Timing.cpp b/flang/lib/Support/Timing.cpp
index ee8309a950eec8..41cb2be8269070 100644
--- a/flang/lib/Support/Timing.cpp
+++ b/flang/lib/Support/Timing.cpp
@@ -1,4 +1,4 @@
-//===- Timing.cpp - Execution time measurement facilities -----------------===//
+//===-- lib/Support/Timing.cpp ----------------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.



More information about the llvm-branch-commits mailing list