diff options
author | Michael Kruse <llvm-project@meinersbur.de> | 2025-02-06 15:29:10 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-02-06 15:29:10 +0100 |
commit | b815a3942a0b0a9e7aab6b269ffdb0e93abc4368 (patch) | |
tree | dd12bb573072dfdc3bc74fc776d4493effa5e3eb /flang/lib | |
parent | f48d9e95d4ccd6ad2a7f53eb9db3e439c40c9dbf (diff) | |
download | llvm-b815a3942a0b0a9e7aab6b269ffdb0e93abc4368.zip llvm-b815a3942a0b0a9e7aab6b269ffdb0e93abc4368.tar.gz llvm-b815a3942a0b0a9e7aab6b269ffdb0e93abc4368.tar.bz2 |
[Flang] Move non-common headers to FortranSupport (#124416)
Move non-common files from FortranCommon to FortranSupport (analogous to
LLVMSupport) such that
* declarations and definitions that are only used by the Flang compiler,
but not by the runtime, are moved to FortranSupport
* declarations and definitions that are used by both ("common"), the
compiler and the runtime, remain in FortranCommon
* generic STL-like/ADT/utility classes and algorithms remain in
FortranCommon
This allows a for cleaner separation between compiler and runtime
components, which are compiled differently. For instance, runtime
sources must not use STL's `<optional>` which causes problems with CUDA
support. Instead, the surrogate header `flang/Common/optional.h` must be
used. This PR fixes this for `fast-int-sel.h`.
Declarations in include/Runtime are also used by both, but are
header-only. `ISO_Fortran_binding_wrapper.h`, a header used by compiler
and runtime, is also moved into FortranCommon.
Diffstat (limited to 'flang/lib')
54 files changed, 124 insertions, 119 deletions
diff --git a/flang/lib/CMakeLists.txt b/flang/lib/CMakeLists.txt index 2182e84..05c3535 100644 --- a/flang/lib/CMakeLists.txt +++ b/flang/lib/CMakeLists.txt @@ -1,4 +1,3 @@ -add_subdirectory(Common) add_subdirectory(Evaluate) add_subdirectory(Decimal) add_subdirectory(Lower) diff --git a/flang/lib/Common/CMakeLists.txt b/flang/lib/Common/CMakeLists.txt deleted file mode 100644 index 4b5df0a..0000000 --- a/flang/lib/Common/CMakeLists.txt +++ /dev/null @@ -1,52 +0,0 @@ -find_first_existing_vc_file("${LLVM_MAIN_SRC_DIR}" llvm_vc) -find_first_existing_vc_file("${FLANG_SOURCE_DIR}" flang_vc) - -# The VC revision include that we want to generate. -set(version_inc "${CMAKE_CURRENT_BINARY_DIR}/VCSVersion.inc") - -set(generate_vcs_version_script "${LLVM_CMAKE_DIR}/GenerateVersionFromVCS.cmake") - -if(llvm_vc AND LLVM_APPEND_VC_REV) - set(llvm_source_dir ${LLVM_MAIN_SRC_DIR}) -endif() -if(flang_vc AND LLVM_APPEND_VC_REV) - set(flang_source_dir ${FLANG_SOURCE_DIR}) -endif() - -# Create custom target to generate the VC revision include. -add_custom_command(OUTPUT "${version_inc}" - DEPENDS "${llvm_vc}" "${flang_vc}" "${generate_vcs_version_script}" - COMMAND ${CMAKE_COMMAND} "-DNAMES=\"LLVM;FLANG\"" - "-DLLVM_SOURCE_DIR=${llvm_source_dir}" - "-DFLANG_SOURCE_DIR=${flang_source_dir}" - "-DHEADER_FILE=${version_inc}" - "-DLLVM_FORCE_VC_REVISION=${LLVM_FORCE_VC_REVISION}" - "-DLLVM_FORCE_VC_REPOSITORY=${LLVM_FORCE_VC_REPOSITORY}" - -P "${generate_vcs_version_script}") - -# Mark the generated header as being generated. -set_source_files_properties("${version_inc}" - PROPERTIES GENERATED TRUE - HEADER_FILE_ONLY TRUE) - -if(FLANG_VENDOR) - set_source_files_properties(Version.cpp - PROPERTIES COMPILE_DEFINITIONS "FLANG_VENDOR=\"${FLANG_VENDOR} \"") -endif() - -add_flang_library(FortranCommon - Fortran.cpp - Fortran-features.cpp - default-kinds.cpp - idioms.cpp - LangOptions.cpp - OpenMP-utils.cpp - Version.cpp - ${version_inc} - - LINK_COMPONENTS - Support - - MLIR_LIBS - MLIRIR -) diff --git a/flang/lib/Decimal/CMakeLists.txt b/flang/lib/Decimal/CMakeLists.txt index 880b190..2fd2a42 100644 --- a/flang/lib/Decimal/CMakeLists.txt +++ b/flang/lib/Decimal/CMakeLists.txt @@ -1,3 +1,11 @@ +#===-- lib/Decimal/CMakeLists.txt ------------------------------------------===# +# +# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +# See https://llvm.org/LICENSE.txt for license information. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +# +#===------------------------------------------------------------------------===# + if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) cmake_minimum_required(VERSION 3.20.0) diff --git a/flang/lib/Evaluate/CMakeLists.txt b/flang/lib/Evaluate/CMakeLists.txt index b38f450..e0bdb6b 100644 --- a/flang/lib/Evaluate/CMakeLists.txt +++ b/flang/lib/Evaluate/CMakeLists.txt @@ -60,7 +60,7 @@ add_flang_library(FortranEvaluate variable.cpp LINK_LIBS - FortranCommon + FortranSupport FortranDecimal FortranParser ${LIBPGMATH} diff --git a/flang/lib/Evaluate/call.cpp b/flang/lib/Evaluate/call.cpp index c5b50e8..f77df92 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/formatting.cpp b/flang/lib/Evaluate/formatting.cpp index f3a53c1..c4c3998 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.cpp b/flang/lib/Evaluate/intrinsics.cpp index 69ae69b..5c9527c 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/Frontend/CMakeLists.txt b/flang/lib/Frontend/CMakeLists.txt index d063ed3..81eef2d 100644 --- a/flang/lib/Frontend/CMakeLists.txt +++ b/flang/lib/Frontend/CMakeLists.txt @@ -27,7 +27,7 @@ add_flang_library(flangFrontend FortranParser FortranSemantics FortranEvaluate - FortranCommon + FortranSupport FortranLower FortranSupport FIRDialect diff --git a/flang/lib/Frontend/CompilerInstance.cpp b/flang/lib/Frontend/CompilerInstance.cpp index dfd15b9..b1fa32e 100644 --- a/flang/lib/Frontend/CompilerInstance.cpp +++ b/flang/lib/Frontend/CompilerInstance.cpp @@ -11,12 +11,12 @@ //===----------------------------------------------------------------------===// #include "flang/Frontend/CompilerInstance.h" -#include "flang/Common/Fortran-features.h" #include "flang/Frontend/CompilerInvocation.h" #include "flang/Frontend/TextDiagnosticPrinter.h" #include "flang/Parser/parsing.h" #include "flang/Parser/provenance.h" #include "flang/Semantics/semantics.h" +#include "flang/Support/Fortran-features.h" #include "flang/Support/Timing.h" #include "mlir/Support/RawOstreamExtras.h" #include "clang/Basic/DiagnosticFrontend.h" diff --git a/flang/lib/Frontend/CompilerInvocation.cpp b/flang/lib/Frontend/CompilerInvocation.cpp index a2c1d3e..3eb413e 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 b0545a7..b7674bd 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 d6bde8e..a31629b 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 8a4ed1c..c9b2497 100644 --- a/flang/lib/Lower/CMakeLists.txt +++ b/flang/lib/Lower/CMakeLists.txt @@ -56,7 +56,7 @@ add_flang_library(FortranLower FIRSupport FIRTransforms HLFIRDialect - FortranCommon + FortranSupport FortranParser FortranEvaluate FortranSemantics diff --git a/flang/lib/Lower/CallInterface.cpp b/flang/lib/Lower/CallInterface.cpp index ab421d8..226ba1e 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 d9ae502..b33baf9 100644 --- a/flang/lib/Lower/ConvertExpr.cpp +++ b/flang/lib/Lower/ConvertExpr.cpp @@ -11,7 +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" @@ -52,6 +51,7 @@ #include "flang/Semantics/symbol.h" #include "flang/Semantics/tools.h" #include "flang/Semantics/type.h" +#include "flang/Support/default-kinds.h" #include "mlir/Dialect/Func/IR/FuncOps.h" #include "llvm/ADT/TypeSwitch.h" #include "llvm/Support/CommandLine.h" diff --git a/flang/lib/Lower/OpenMP/OpenMP.cpp b/flang/lib/Lower/OpenMP/OpenMP.cpp index 0ae04ed9..94c1988 100644 --- a/flang/lib/Lower/OpenMP/OpenMP.cpp +++ b/flang/lib/Lower/OpenMP/OpenMP.cpp @@ -18,7 +18,6 @@ #include "Decomposer.h" #include "ReductionProcessor.h" #include "Utils.h" -#include "flang/Common/OpenMP-utils.h" #include "flang/Common/idioms.h" #include "flang/Lower/Bridge.h" #include "flang/Lower/ConvertExpr.h" @@ -35,6 +34,7 @@ #include "flang/Parser/parse-tree.h" #include "flang/Semantics/openmp-directive-sets.h" #include "flang/Semantics/tools.h" +#include "flang/Support/OpenMP-utils.h" #include "mlir/Dialect/ControlFlow/IR/ControlFlowOps.h" #include "mlir/Dialect/OpenMP/OpenMPDialect.h" #include "mlir/Transforms/RegionUtils.h" diff --git a/flang/lib/Optimizer/CodeGen/TypeConverter.cpp b/flang/lib/Optimizer/CodeGen/TypeConverter.cpp index 0eace90..89f4984 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 0b57a10..67d918c 100644 --- a/flang/lib/Optimizer/Dialect/FIRType.cpp +++ b/flang/lib/Optimizer/Dialect/FIRType.cpp @@ -11,7 +11,7 @@ //===----------------------------------------------------------------------===// #include "flang/Optimizer/Dialect/FIRType.h" -#include "flang/ISO_Fortran_binding_wrapper.h" +#include "flang/Common/ISO_Fortran_binding_wrapper.h" #include "flang/Optimizer/Builder/Todo.h" #include "flang/Optimizer/Dialect/FIRDialect.h" #include "flang/Optimizer/Dialect/Support/KindMapping.h" diff --git a/flang/lib/Optimizer/OpenMP/CMakeLists.txt b/flang/lib/Optimizer/OpenMP/CMakeLists.txt index c8509cc..86ae93f 100644 --- a/flang/lib/Optimizer/OpenMP/CMakeLists.txt +++ b/flang/lib/Optimizer/OpenMP/CMakeLists.txt @@ -21,7 +21,7 @@ add_flang_library(FlangOpenMPTransforms FIRDialect FIRDialectSupport FIRSupport - FortranCommon + FortranSupport HLFIRDialect MLIR_LIBS diff --git a/flang/lib/Optimizer/OpenMP/GenericLoopConversion.cpp b/flang/lib/Optimizer/OpenMP/GenericLoopConversion.cpp index 3e742f7..3512a537 100644 --- a/flang/lib/Optimizer/OpenMP/GenericLoopConversion.cpp +++ b/flang/lib/Optimizer/OpenMP/GenericLoopConversion.cpp @@ -6,7 +6,7 @@ // //===----------------------------------------------------------------------===// -#include "flang/Common/OpenMP-utils.h" +#include "flang/Support/OpenMP-utils.h" #include "mlir/Dialect/Func/IR/FuncOps.h" #include "mlir/Dialect/OpenMP/OpenMPDialect.h" diff --git a/flang/lib/Optimizer/Passes/CMakeLists.txt b/flang/lib/Optimizer/Passes/CMakeLists.txt index eb25beb..1c19a57 100644 --- a/flang/lib/Optimizer/Passes/CMakeLists.txt +++ b/flang/lib/Optimizer/Passes/CMakeLists.txt @@ -5,14 +5,11 @@ add_flang_library(flangPasses CommandLineOpts.cpp Pipelines.cpp - DEPENDS - FortranCommon - LINK_LIBS FIRCodeGen FIRTransforms FlangOpenMPTransforms - FortranCommon + FortranSupport HLFIRTransforms LINK_COMPONENTS diff --git a/flang/lib/Optimizer/Transforms/AddDebugInfo.cpp b/flang/lib/Optimizer/Transforms/AddDebugInfo.cpp index 6991574..49c9a73 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 eb59045..d0bd67a 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 9c550f9..50994fb 100644 --- a/flang/lib/Optimizer/Transforms/CMakeLists.txt +++ b/flang/lib/Optimizer/Transforms/CMakeLists.txt @@ -46,7 +46,7 @@ add_flang_library(FIRTransforms FIRDialect FIRDialectSupport FIRSupport - FortranCommon + FortranSupport HLFIRDialect MLIR_LIBS diff --git a/flang/lib/Optimizer/Transforms/CUFDeviceGlobal.cpp b/flang/lib/Optimizer/Transforms/CUFDeviceGlobal.cpp index 7486dde..3f13a18 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 4611a18..2a95e41 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 549498f..1f0576a 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" @@ -22,6 +21,7 @@ #include "flang/Runtime/CUDA/memory.h" #include "flang/Runtime/CUDA/pointer.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 4f6974e..3d84eaa 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 0aa89f1..1f34955 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 fa6a7b2..df2887f 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 bd3e49a..acb6858 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 d311167..54a2456 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 d364671..76fe3d7 100644 --- a/flang/lib/Parser/CMakeLists.txt +++ b/flang/lib/Parser/CMakeLists.txt @@ -25,7 +25,7 @@ add_flang_library(FortranParser user-state.cpp LINK_LIBS - FortranCommon + FortranSupport LINK_COMPONENTS Support diff --git a/flang/lib/Parser/basic-parsers.h b/flang/lib/Parser/basic-parsers.h index 1a8c14e..7e69d41 100644 --- a/flang/lib/Parser/basic-parsers.h +++ b/flang/lib/Parser/basic-parsers.h @@ -22,7 +22,6 @@ // 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" @@ -30,6 +29,7 @@ #include "flang/Parser/parse-state.h" #include "flang/Parser/provenance.h" #include "flang/Parser/user-state.h" +#include "flang/Support/Fortran-features.h" #include <cstring> #include <functional> #include <list> diff --git a/flang/lib/Parser/prescan.h b/flang/lib/Parser/prescan.h index 08041f9..e2440ad 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 243f586..cd91fbe4 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 "llvm/Support/raw_ostream.h" #include <algorithm> #include <cinttypes> diff --git a/flang/lib/Semantics/CMakeLists.txt b/flang/lib/Semantics/CMakeLists.txt index 7855ae7..00108dd 100644 --- a/flang/lib/Semantics/CMakeLists.txt +++ b/flang/lib/Semantics/CMakeLists.txt @@ -53,7 +53,7 @@ add_flang_library(FortranSemantics omp_gen LINK_LIBS - FortranCommon + FortranSupport FortranParser FortranEvaluate diff --git a/flang/lib/Semantics/check-return.cpp b/flang/lib/Semantics/check-return.cpp index 22729f6..52220a5 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 2e602d3..b227bba 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-stop.cpp b/flang/lib/Semantics/check-stop.cpp index 43535b0..aabd520 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 d8cc460..7486ac8 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 <list> #include <map> diff --git a/flang/lib/Semantics/expression.cpp b/flang/lib/Semantics/expression.cpp index f9fa4a5..6949e56 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/resolve-names-utils.cpp b/flang/lib/Semantics/resolve-names-utils.cpp index 347f54e0..742bb74 100644 --- a/flang/lib/Semantics/resolve-names-utils.cpp +++ b/flang/lib/Semantics/resolve-names-utils.cpp @@ -7,8 +7,6 @@ //===----------------------------------------------------------------------===// #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" @@ -20,6 +18,8 @@ #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 <initializer_list> #include <variant> diff --git a/flang/lib/Semantics/resolve-names.cpp b/flang/lib/Semantics/resolve-names.cpp index fbf43d4..e64abe6 100644 --- a/flang/lib/Semantics/resolve-names.cpp +++ b/flang/lib/Semantics/resolve-names.cpp @@ -13,8 +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" @@ -38,6 +36,8 @@ #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 "llvm/Support/raw_ostream.h" #include <list> #include <map> diff --git a/flang/lib/Semantics/semantics.cpp b/flang/lib/Semantics/semantics.cpp index 58dc1f2..10a0103 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 9ebfbbb..7544731 100644 --- a/flang/lib/Semantics/tools.cpp +++ b/flang/lib/Semantics/tools.cpp @@ -7,7 +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" @@ -17,6 +16,7 @@ #include "flang/Semantics/symbol.h" #include "flang/Semantics/tools.h" #include "flang/Semantics/type.h" +#include "flang/Support/Fortran.h" #include "llvm/Support/raw_ostream.h" #include <algorithm> #include <set> diff --git a/flang/lib/Support/CMakeLists.txt b/flang/lib/Support/CMakeLists.txt index 12183f5..4ee3815 100644 --- a/flang/lib/Support/CMakeLists.txt +++ b/flang/lib/Support/CMakeLists.txt @@ -1,9 +1,62 @@ +#===-- lib/Support/CMakeLists.txt ------------------------------------------===# +# +# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +# See https://llvm.org/LICENSE.txt for license information. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +# +#===------------------------------------------------------------------------===# + +find_first_existing_vc_file("${LLVM_MAIN_SRC_DIR}" llvm_vc) +find_first_existing_vc_file("${FLANG_SOURCE_DIR}" flang_vc) + +# The VC revision include that we want to generate. +set(version_inc "${CMAKE_CURRENT_BINARY_DIR}/VCSVersion.inc") + +set(generate_vcs_version_script "${LLVM_CMAKE_DIR}/GenerateVersionFromVCS.cmake") + +if(llvm_vc AND LLVM_APPEND_VC_REV) + set(llvm_source_dir ${LLVM_MAIN_SRC_DIR}) +endif() +if(flang_vc AND LLVM_APPEND_VC_REV) + set(flang_source_dir ${FLANG_SOURCE_DIR}) +endif() + +# Create custom target to generate the VC revision include. +add_custom_command(OUTPUT "${version_inc}" + DEPENDS "${llvm_vc}" "${flang_vc}" "${generate_vcs_version_script}" + COMMAND ${CMAKE_COMMAND} "-DNAMES=\"LLVM;FLANG\"" + "-DLLVM_SOURCE_DIR=${llvm_source_dir}" + "-DFLANG_SOURCE_DIR=${flang_source_dir}" + "-DHEADER_FILE=${version_inc}" + "-DLLVM_FORCE_VC_REVISION=${LLVM_FORCE_VC_REVISION}" + "-DLLVM_FORCE_VC_REPOSITORY=${LLVM_FORCE_VC_REPOSITORY}" + -P "${generate_vcs_version_script}") + +# Mark the generated header as being generated. +set_source_files_properties("${version_inc}" + PROPERTIES GENERATED TRUE + HEADER_FILE_ONLY TRUE) + +if(FLANG_VENDOR) + set_source_files_properties(Version.cpp + PROPERTIES COMPILE_DEFINITIONS "FLANG_VENDOR=\"${FLANG_VENDOR} \"") +endif() + add_flang_library(FortranSupport + default-kinds.cpp + Fortran.cpp + Fortran-features.cpp + idioms.cpp + LangOptions.cpp + OpenMP-utils.cpp Timing.cpp + Version.cpp + ${version_inc} LINK_COMPONENTS Support MLIR_LIBS + MLIRIR MLIRSupport ) diff --git a/flang/lib/Common/Fortran-features.cpp b/flang/lib/Support/Fortran-features.cpp index e2601e1..bbeb4b1 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 index eec8341..746b7c9 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 index 415c715..273274f 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 index 47e89fe..178a6e3 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. @@ -6,7 +6,7 @@ // //===----------------------------------------------------------------------===// -#include "flang/Common/OpenMP-utils.h" +#include "flang/Support/OpenMP-utils.h" #include "mlir/IR/OpDefinition.h" diff --git a/flang/lib/Common/Version.cpp b/flang/lib/Support/Version.cpp index d67255f..8ee4908 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 index d2ca910..b763f8e 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 index 536a5c2..906a4c1 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. |