diff --git a/flang/include/flang/Frontend/LangOptions.def b/flang/include/flang/Common/LangOptions.def similarity index 100% rename from flang/include/flang/Frontend/LangOptions.def rename to flang/include/flang/Common/LangOptions.def diff --git a/flang/include/flang/Frontend/LangOptions.h b/flang/include/flang/Common/LangOptions.h similarity index 86% rename from flang/include/flang/Frontend/LangOptions.h rename to flang/include/flang/Common/LangOptions.h index 57d86d46df5ab1..c75229ae7f7c2a 100644 --- a/flang/include/flang/Frontend/LangOptions.h +++ b/flang/include/flang/Common/LangOptions.h @@ -12,15 +12,15 @@ // //===----------------------------------------------------------------------===// -#ifndef FORTRAN_FRONTEND_LANGOPTIONS_H -#define FORTRAN_FRONTEND_LANGOPTIONS_H +#ifndef FORTRAN_COMMON_LANGOPTIONS_H +#define FORTRAN_COMMON_LANGOPTIONS_H #include #include #include "llvm/TargetParser/Triple.h" -namespace Fortran::frontend { +namespace Fortran::common { /// Bitfields of LangOptions, split out from LangOptions to ensure /// that this large collection of bitfields is a trivial class type. @@ -37,12 +37,12 @@ class LangOptionsBase { #define LANGOPT(Name, Bits, Default) unsigned Name : Bits; #define ENUM_LANGOPT(Name, Type, Bits, Default) -#include "flang/Frontend/LangOptions.def" +#include "flang/Common/LangOptions.def" protected: #define LANGOPT(Name, Bits, Default) #define ENUM_LANGOPT(Name, Type, Bits, Default) unsigned Name : Bits; -#include "flang/Frontend/LangOptions.def" +#include "flang/Common/LangOptions.def" }; /// Tracks various options which control the dialect of Fortran that is @@ -55,7 +55,7 @@ class LangOptions : public LangOptionsBase { #define ENUM_LANGOPT(Name, Type, Bits, Default) \ Type get##Name() const { return static_cast(Name); } \ void set##Name(Type Value) { Name = static_cast(Value); } -#include "flang/Frontend/LangOptions.def" +#include "flang/Common/LangOptions.def" /// Name of the IR file that contains the result of the OpenMP target /// host code generation. @@ -67,6 +67,6 @@ class LangOptions : public LangOptionsBase { LangOptions(); }; -} // end namespace Fortran::frontend +} // end namespace Fortran::common -#endif // FORTRAN_FRONTEND_LANGOPTIONS_H +#endif // FORTRAN_COMMON_LANGOPTIONS_H diff --git a/flang/include/flang/Frontend/CompilerInvocation.h b/flang/include/flang/Frontend/CompilerInvocation.h index d1646f585cf850..50d908d0832024 100644 --- a/flang/include/flang/Frontend/CompilerInvocation.h +++ b/flang/include/flang/Frontend/CompilerInvocation.h @@ -13,9 +13,9 @@ #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/LangOptions.h" #include "flang/Frontend/PreprocessorOptions.h" #include "flang/Frontend/TargetOptions.h" #include "flang/Lower/LoweringOptions.h" @@ -84,7 +84,7 @@ class CompilerInvocation : public CompilerInvocationBase { Fortran::frontend::CodeGenOptions codeGenOpts; /// Options controlling language dialect. - Fortran::frontend::LangOptions langOpts; + Fortran::common::LangOptions langOpts; // The original invocation of the compiler driver. // This string will be set as the return value from the COMPILER_OPTIONS @@ -158,8 +158,8 @@ class CompilerInvocation : public CompilerInvocationBase { CodeGenOptions &getCodeGenOpts() { return codeGenOpts; } const CodeGenOptions &getCodeGenOpts() const { return codeGenOpts; } - LangOptions &getLangOpts() { return langOpts; } - const LangOptions &getLangOpts() const { return langOpts; } + Fortran::common::LangOptions &getLangOpts() { return langOpts; } + const Fortran::common::LangOptions &getLangOpts() const { return langOpts; } Fortran::lower::LoweringOptions &getLoweringOpts() { return loweringOpts; } const Fortran::lower::LoweringOptions &getLoweringOpts() const { diff --git a/flang/include/flang/Tools/CrossToolHelpers.h b/flang/include/flang/Tools/CrossToolHelpers.h index 75fd783af237d0..3e703de545950c 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/Frontend/LangOptions.h" #include #include "mlir/Dialect/OpenMP/OpenMPDialect.h" @@ -145,7 +145,7 @@ struct OffloadModuleOpts { OMPTargetTriples(OMPTargetTriples.begin(), OMPTargetTriples.end()), NoGPULib(NoGPULib) {} - OffloadModuleOpts(Fortran::frontend::LangOptions &Opts) + OffloadModuleOpts(Fortran::common::LangOptions &Opts) : OpenMPTargetDebug(Opts.OpenMPTargetDebug), OpenMPTeamSubscription(Opts.OpenMPTeamSubscription), OpenMPThreadSubscription(Opts.OpenMPThreadSubscription), diff --git a/flang/lib/Common/CMakeLists.txt b/flang/lib/Common/CMakeLists.txt index c6f818ad27cd19..54eb1de8614d50 100644 --- a/flang/lib/Common/CMakeLists.txt +++ b/flang/lib/Common/CMakeLists.txt @@ -40,6 +40,7 @@ add_flang_library(FortranCommon Fortran-features.cpp default-kinds.cpp idioms.cpp + LangOptions.cpp Version.cpp ${version_inc} diff --git a/flang/lib/Frontend/LangOptions.cpp b/flang/lib/Common/LangOptions.cpp similarity index 82% rename from flang/lib/Frontend/LangOptions.cpp rename to flang/lib/Common/LangOptions.cpp index a08cb363384c6f..415c715156e7bf 100644 --- a/flang/lib/Frontend/LangOptions.cpp +++ b/flang/lib/Common/LangOptions.cpp @@ -10,15 +10,15 @@ // //===----------------------------------------------------------------------===// -#include "flang/Frontend/LangOptions.h" +#include "flang/Common/LangOptions.h" #include -namespace Fortran::frontend { +namespace Fortran::common { LangOptions::LangOptions() { #define LANGOPT(Name, Bits, Default) Name = Default; #define ENUM_LANGOPT(Name, Type, Bits, Default) set##Name(Default); -#include "flang/Frontend/LangOptions.def" +#include "flang/Common/LangOptions.def" } -} // end namespace Fortran::frontend +} // end namespace Fortran::common diff --git a/flang/lib/Frontend/CMakeLists.txt b/flang/lib/Frontend/CMakeLists.txt index ecdcc73d61ec1f..875481a567ac92 100644 --- a/flang/lib/Frontend/CMakeLists.txt +++ b/flang/lib/Frontend/CMakeLists.txt @@ -8,7 +8,6 @@ add_flang_library(flangFrontend FrontendAction.cpp FrontendActions.cpp FrontendOptions.cpp - LangOptions.cpp TextDiagnosticPrinter.cpp TextDiagnosticBuffer.cpp TextDiagnostic.cpp diff --git a/flang/lib/Frontend/CompilerInvocation.cpp b/flang/lib/Frontend/CompilerInvocation.cpp index f1fdbb73e14aea..d40f0c03716925 100644 --- a/flang/lib/Frontend/CompilerInvocation.cpp +++ b/flang/lib/Frontend/CompilerInvocation.cpp @@ -1138,17 +1138,17 @@ static bool parseOpenMPArgs(CompilerInvocation &res, llvm::opt::ArgList &args, static bool parseFloatingPointArgs(CompilerInvocation &invoc, llvm::opt::ArgList &args, clang::DiagnosticsEngine &diags) { - LangOptions &opts = invoc.getLangOpts(); + Fortran::common::LangOptions &opts = invoc.getLangOpts(); if (const llvm::opt::Arg *a = args.getLastArg(clang::driver::options::OPT_ffp_contract)) { const llvm::StringRef val = a->getValue(); - enum LangOptions::FPModeKind fpContractMode; + enum Fortran::common::LangOptions::FPModeKind fpContractMode; if (val == "off") - fpContractMode = LangOptions::FPM_Off; + fpContractMode = Fortran::common::LangOptions::FPM_Off; else if (val == "fast") - fpContractMode = LangOptions::FPM_Fast; + fpContractMode = Fortran::common::LangOptions::FPM_Fast; else { diags.Report(clang::diag::err_drv_unsupported_option_argument) << a->getSpelling() << val; @@ -1189,7 +1189,7 @@ static bool parseFloatingPointArgs(CompilerInvocation &invoc, opts.ReciprocalMath = true; opts.ApproxFunc = true; opts.NoSignedZeros = true; - opts.setFPContractMode(LangOptions::FPM_Fast); + opts.setFPContractMode(Fortran::common::LangOptions::FPM_Fast); } return true; @@ -1222,7 +1222,7 @@ static bool parseVScaleArgs(CompilerInvocation &invoc, llvm::opt::ArgList &args, return false; } - LangOptions &opts = invoc.getLangOpts(); + Fortran::common::LangOptions &opts = invoc.getLangOpts(); if (vscaleMin) { llvm::StringRef argValue = llvm::StringRef(vscaleMin->getValue()); unsigned vscaleMinVal; @@ -1584,14 +1584,14 @@ void CompilerInvocation::setLoweringOptions() { loweringOpts.setOptimizeTranspose(codegenOpts.OptimizationLevel > 0); loweringOpts.setUnderscoring(codegenOpts.Underscoring); - const LangOptions &langOptions = getLangOpts(); + const Fortran::common::LangOptions &langOptions = getLangOpts(); Fortran::common::MathOptionsBase &mathOpts = loweringOpts.getMathOptions(); // TODO: when LangOptions are finalized, we can represent // the math related options using Fortran::commmon::MathOptionsBase, // so that we can just copy it into LoweringOptions. mathOpts .setFPContractEnabled(langOptions.getFPContractMode() == - LangOptions::FPM_Fast) + Fortran::common::LangOptions::FPM_Fast) .setNoHonorInfs(langOptions.NoHonorInfs) .setNoHonorNaNs(langOptions.NoHonorNaNs) .setApproxFunc(langOptions.ApproxFunc)