Skip to content

Commit 488ff60

Browse files
schweitzpgibryanpkc
authored andcommitted
Port Classic Flang to LLVM 15
This commit cherry-picks 427c0e8 from the release_14x branch, which is a combination of the following legacy patches: Commit 82b38d2: [ClassicFlang] Port release_90 changes from flang-compiler/llvm Cherry-picked commit 2085211cfcca70411dc63f0d08763facc8a02090 by Eric Schweitz, resolved merge conflicts, fixed build failures (e.g. adapted CGDebugInfo.cpp to the new API), and fixed the DIGlobalVariable unit tests, which have been broken since commit edfad65eebdf045b050f37380b6b61d673513982. Commit 885dd87e5fdc: [DebugInfo] Removal of DIFortranArrayType and DIFortranSubrange These extensions are no more required after merge of below PR. Commit 5c9b2e0867d5: Modification to incorporate comments from @bryanpkc. Commit 822de2c: [AsmPrinter] Fix redundant names and types A bug was introduced in 82b38d2 while cherry-picking a DIGlobalVariable-related patch. Commit 45a70a8: Port driver changes from release/11x Cherry-picked c51f89679135f84675f492d560ec5535c2000cfe by Varun Jayathirtha from release_90, and resolved merge conflicts. To avoid conflicts with the new Flang, lib/Driver/ToolChains/Flang.{cpp,h} have been renamed to ClassicFlang.{cpp,h}, and the ENABLE_CLASSIC_FLANG macro is introduced to select which incarnation of Flang to build. The macro is set by running CMake with -DLLVM_ENABLE_CLASSIC_FLANG. After merge with LLVM 11: Move flang options to the end of the definitions list. Commit a9a8036: Port Classic Flang to LLVM 13 File changes to TargetLibraryInfo and DebugLocEntry to adapt to the code from release/13.x and make it work. Comment out the changes due a segmentation fault, code need to be reviewed properly once all commits are in Commit fe989b7: Fix -fveclib=PGMATH The use of #ifdef in include/clang/Driver/Options.td was incorrect and unsupported. As a result -fveclib=PGMATH was silently ignored, and in LLVM 12, it causes the invocation to fail. This patch unguards the option so that it is parsed correctly, but lets the FLANG_LLVM_EXTENSIONS macro continue to toggle the feature. Commit 7c224ae: Fix use of classic Flang as preprocessor Commit 8403c83: Merge FLANG_LLVM_EXTENSIONS macro into ENABLE_CLASSIC_FLANG Commit 486741e: Fix test failures when in classic Flang mode Add a new lit feature tag "classic_flang" to select which tests can or cannot be run when the driver is built for classic Flang. Handle LLVM_ENABLE_CLASSIC_FLANG in llvm/cmake/modules/HandleLLVMOptions.cmake instead of clang/CMakeLists.txt so that macro works in both clang and llvm. Commit a10f592: Port Classic Flang to LLVM 13 LLVM port from release_12x to release_13x, changes done in order to make project able to be build. Commit d385321 (partial): Change to Options.td in order to add the correct invocation for ffixed_line_length_VALUE. This commit also includes the following legacy patch: Commit 5da2c11: Add DebugInfo tests Commit c379c8d: [ClassicFlang][Driver] Correct the LLVM version passed by the Driver Commit 33013f4: [ClassicFlang][Driver] Fix warnings * -Wsuggest-override for ClassicFlangMacroBuilder::defineMacro Signed-off-by: Itay Bookstein <[email protected]>
1 parent 39074b4 commit 488ff60

File tree

75 files changed

+2881
-107
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+2881
-107
lines changed

clang/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,11 @@ if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
413413
endif()
414414
endif()
415415

416+
option(LLVM_ENABLE_CLASSIC_FLANG "Build support for classic Flang instead of the new built-in Flang" OFF)
417+
if(LLVM_ENABLE_CLASSIC_FLANG)
418+
add_definitions( -DENABLE_CLASSIC_FLANG )
419+
endif()
420+
416421
option(CLANG_BUILD_TOOLS
417422
"Build the Clang tools. If OFF, just generate build targets." ON)
418423

clang/include/clang/Basic/DiagnosticDriverKinds.td

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,10 @@ def err_drv_invalid_linker_name : Error<
156156
"invalid linker name in argument '%0'">;
157157
def err_drv_invalid_rtlib_name : Error<
158158
"invalid runtime library name in argument '%0'">;
159+
def err_drv_invalid_allocatable_mode : Error<
160+
"invalid semantic mode for assignments to allocatables in argument '%0'">;
161+
def err_drv_unsupported_fixed_line_length : Error<
162+
"unsupported fixed-format line length in argument '%0'">;
159163
def err_drv_unsupported_rtlib_for_platform : Error<
160164
"unsupported runtime library '%0' for platform '%1'">;
161165
def err_drv_invalid_unwindlib_name : Error<
@@ -384,6 +388,8 @@ def err_drv_small_columns : Error<
384388
def warn_drv_fraw_string_literals_in_cxx11 : Warning<
385389
"ignoring '-f%select{no-|}0raw-string-literals', which is only valid for C and C++ standards before C++11">,
386390
InGroup<UnusedCommandLineArgument>;
391+
def err_drv_clang_unsupported_minfo_arg : Error<
392+
"'%0' option does not support '%1' value">;
387393

388394
def err_drv_invalid_malign_branch_EQ : Error<
389395
"invalid argument '%0' to -malign-branch=; each element must be one of: %1">;

clang/include/clang/Basic/MacroBuilder.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,13 @@ class MacroBuilder {
2424
raw_ostream &Out;
2525
public:
2626
MacroBuilder(raw_ostream &Output) : Out(Output) {}
27+
virtual ~MacroBuilder() {}
2728

2829
/// Append a \#define line for macro of the form "\#define Name Value\n".
2930
/// If DeprecationMsg is provided, also append a pragma to deprecate the
3031
/// defined macro.
31-
void defineMacro(const Twine &Name, const Twine &Value = "1",
32-
Twine DeprecationMsg = "") {
32+
virtual void defineMacro(const Twine &Name, const Twine &Value = "1",
33+
Twine DeprecationMsg = "") {
3334
Out << "#define " << Name << ' ' << Value << '\n';
3435
if (!DeprecationMsg.isTriviallyEmpty())
3536
Out << "#pragma clang deprecated(" << Name << ", \"" << DeprecationMsg

clang/include/clang/Basic/Sanitizers.def

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,8 @@ SANITIZER("signed-integer-overflow", SignedIntegerOverflow)
116116
SANITIZER("unreachable", Unreachable)
117117
SANITIZER("vla-bound", VLABound)
118118
SANITIZER("vptr", Vptr)
119+
// fortran contiguous pointer checks
120+
SANITIZER("discontiguous", Discontiguous)
119121

120122
// IntegerSanitizer
121123
SANITIZER("unsigned-integer-overflow", UnsignedIntegerOverflow)

clang/include/clang/Driver/Action.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ class Action {
6262
AnalyzeJobClass,
6363
MigrateJobClass,
6464
CompileJobClass,
65+
FortranFrontendJobClass,
6566
BackendJobClass,
6667
AssembleJobClass,
6768
LinkJobClass,
@@ -471,6 +472,16 @@ class MigrateJobAction : public JobAction {
471472
}
472473
};
473474

475+
class FortranFrontendJobAction : public JobAction {
476+
void anchor() override;
477+
public:
478+
FortranFrontendJobAction(Action *Input, types::ID OutputType);
479+
480+
static bool classof(const Action *A) {
481+
return A->getKind() == FortranFrontendJobClass;
482+
}
483+
};
484+
474485
class CompileJobAction : public JobAction {
475486
void anchor() override;
476487

clang/include/clang/Driver/Options.td

Lines changed: 181 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3459,10 +3459,17 @@ def fveclib : Joined<["-"], "fveclib=">, Group<f_Group>,
34593459
HelpTextForVariants<[ClangOption, CC1Option],
34603460
"Use the given vector functions library. "
34613461
"Note: -fveclib={ArmPL,SLEEF} implies -fno-math-errno">,
3462+
#ifdef ENABLE_CLASSIC_FLANG
3463+
Values<"Accelerate,libmvec,MASSV,PGMATH,SVML,SLEEF,Darwin_libsystem_m,ArmPL,AMDLIBM,none">,
3464+
NormalizedValuesScope<"llvm::driver::VectorLibrary">,
3465+
NormalizedValues<["Accelerate", "LIBMVEC", "MASSV", "PGMATH", "SVML", "SLEEF",
3466+
"Darwin_libsystem_m", "ArmPL", "AMDLIBM", "NoLibrary"]>,
3467+
#else
34623468
Values<"Accelerate,libmvec,MASSV,SVML,SLEEF,Darwin_libsystem_m,ArmPL,AMDLIBM,none">,
34633469
NormalizedValuesScope<"llvm::driver::VectorLibrary">,
34643470
NormalizedValues<["Accelerate", "LIBMVEC", "MASSV", "SVML", "SLEEF",
34653471
"Darwin_libsystem_m", "ArmPL", "AMDLIBM", "NoLibrary"]>,
3472+
#endif
34663473
MarshallingInfoEnum<CodeGenOpts<"VecLib">, "NoLibrary">;
34673474
def fno_lax_vector_conversions : Flag<["-"], "fno-lax-vector-conversions">, Group<f_Group>,
34683475
Alias<flax_vector_conversions_EQ>, AliasArgs<["none"]>;
@@ -6937,6 +6944,20 @@ def module_dir : JoinedOrSeparate<["-"], "module-dir">, MetaVarName<"<dir>">,
69376944
It is also added to the list of directories to be searched by an USE statement.
69386945
The default is the current directory.}]>;
69396946

6947+
#ifdef ENABLE_CLASSIC_FLANG
6948+
// Define a group for Fortran source format options.
6949+
def fortran_format_Group : OptionGroup<"Fortran format Group">, Group<gfortran_Group>;
6950+
def ffixed_form : Flag<["-"], "ffixed-form">, Group<fortran_format_Group>,
6951+
HelpText<"Process source files in fixed form">;
6952+
def fno_fixed_form : Flag<["-"], "fno-fixed-form">, Group<fortran_format_Group>,
6953+
HelpText<"Disable fixed-form format for Fortran">;
6954+
def ffree_form : Flag<["-"], "ffree-form">, Group<fortran_format_Group>,
6955+
HelpText<"Process source files in free form">;
6956+
def fno_free_form : Flag<["-"], "fno-free-form">, Group<fortran_format_Group>,
6957+
HelpText<"Disable free-form format for Fortran">;
6958+
def ffixed_line_length_VALUE : Joined<["-"], "ffixed-line-length-">, Group<f_Group>,
6959+
HelpText<"Set line length in fixed-form format Fortran, current supporting only 72 and 132 characters">;
6960+
#else
69406961
def ffixed_form : Flag<["-"], "ffixed-form">, Group<f_Group>,
69416962
HelpText<"Process source files in fixed form">;
69426963
def ffree_form : Flag<["-"], "ffree-form">, Group<f_Group>,
@@ -6946,14 +6967,21 @@ def ffixed_line_length_EQ : Joined<["-"], "ffixed-line-length=">, Group<f_Group>
69466967
DocBrief<[{Set column after which characters are ignored in typical fixed-form lines in the source
69476968
file}]>;
69486969
def ffixed_line_length_VALUE : Joined<["-"], "ffixed-line-length-">, Group<f_Group>, Alias<ffixed_line_length_EQ>;
6970+
#endif
69496971
def fconvert_EQ : Joined<["-"], "fconvert=">, Group<f_Group>,
69506972
HelpText<"Set endian conversion of data for unformatted files">;
69516973
def fdefault_double_8 : Flag<["-"],"fdefault-double-8">, Group<f_Group>,
69526974
HelpText<"Set the default double precision kind to an 8 byte wide type">;
6975+
#ifdef ENABLE_CLASSIC_FLANG
6976+
def fno_default_integer_8 : Flag<["-"], "fno-default-integer-8">, Group<f_Group>;
6977+
#endif
69536978
def fdefault_integer_8 : Flag<["-"],"fdefault-integer-8">, Group<f_Group>,
69546979
HelpText<"Set the default integer and logical kind to an 8 byte wide type">;
69556980
def fdefault_real_8 : Flag<["-"],"fdefault-real-8">, Group<f_Group>,
69566981
HelpText<"Set the default real kind to an 8 byte wide type">;
6982+
#ifdef ENABLE_CLASSIC_FLANG
6983+
def fno_default_real_8 : Flag<["-"], "fno-default-real-8">, Group<f_Group>;
6984+
#endif
69576985
def fdisable_real_3 : Flag<["-"],"fdisable-real-3">, Group<f_Group>,
69586986
HelpText<"Disable real(KIND=3) from TargetCharacteristics">, Flags<[HelpHidden]>;
69596987
def fdisable_real_10 : Flag<["-"],"fdisable-real-10">, Group<f_Group>,
@@ -6972,6 +7000,13 @@ def fintrinsic_modules_path : Separate<["-"], "fintrinsic-modules-path">, Group
69727000
DocBrief<[{This option specifies the location of pre-compiled intrinsic modules,
69737001
if they are not in the default location expected by the compiler.}]>;
69747002

7003+
#ifdef ENABLE_CLASSIC_FLANG
7004+
def fbackslash : Flag<["-"], "fbackslash">, Group<gfortran_Group>,
7005+
HelpText<"Specify that backslash in string introduces an escape character">,
7006+
DocBrief<[{Change the interpretation of backslashes in string literals from
7007+
a single backslash character to "C-style" escape characters.}]>;
7008+
def fno_backslash : Flag<["-"], "fno-backslash">, Group<gfortran_Group>;
7009+
#else
69757010
defm backslash : OptInFC1FFlag<"backslash", "Specify that backslash in string introduces an escape character">;
69767011
defm xor_operator : OptInFC1FFlag<"xor-operator", "Enable .XOR. as a synonym of .NEQV.">;
69777012
defm logical_abbreviations : OptInFC1FFlag<"logical-abbreviations", "Enable logical abbreviations">;
@@ -6984,6 +7019,7 @@ defm unsigned : OptInFC1FFlag<"unsigned", "Enables UNSIGNED type">;
69847019

69857020
def fno_automatic : Flag<["-"], "fno-automatic">, Group<f_Group>,
69867021
HelpText<"Implies the SAVE attribute for non-automatic local objects in subprograms unless RECURSIVE">;
7022+
#endif
69877023

69887024
defm save_main_program : BoolOptionWithoutMarshalling<"f", "save-main-program",
69897025
PosFlag<SetTrue, [], [],
@@ -7002,10 +7038,16 @@ def fhermetic_module_files : Flag<["-"], "fhermetic-module-files">, Group<f_Grou
70027038
HelpText<"Emit hermetic module files (no nested USE association)">;
70037039
} // let Visibility = [FC1Option, FlangOption]
70047040

7041+
#ifdef ENABLE_CLASSIC_FLANG
7042+
def J : JoinedOrSeparate<["-"], "J">,
7043+
Flags<[RenderJoined]>,
7044+
Group<gfortran_Group>;
7045+
#else
70057046
def J : JoinedOrSeparate<["-"], "J">,
70067047
Flags<[RenderJoined]>, Visibility<[FlangOption, FC1Option]>,
70077048
Group<gfortran_Group>,
70087049
Alias<module_dir>;
7050+
#endif
70097051

70107052
//===----------------------------------------------------------------------===//
70117053
// FC1 Options
@@ -9136,3 +9178,142 @@ def wasm_opt : Flag<["--"], "wasm-opt">,
91369178
Group<m_Group>,
91379179
HelpText<"Enable the wasm-opt optimizer (default)">,
91389180
MarshallingInfoNegativeFlag<LangOpts<"NoWasmOpt">>;
9181+
9182+
#ifdef ENABLE_CLASSIC_FLANG
9183+
// gfortran options that we recognize in the driver and pass along when
9184+
// invoking GCC to compile Fortran code.
9185+
def flang_rt_Group : OptionGroup<"Flang runtime library Group">;
9186+
def pgi_fortran_Group : OptionGroup<"PGI Fortran compatibility Group">,
9187+
Flags<[HelpHidden]>;
9188+
9189+
// Classic Flang-specific options
9190+
multiclass BooleanKFlag<string name> {
9191+
def _on : Flag<["-"], "K"#name>;
9192+
def _off : Flag<["-"], "Kno"#name>;
9193+
}
9194+
9195+
multiclass BooleanMFlag<string name> {
9196+
def _on : Flag<["-"], "M"#name>;
9197+
def _off : Flag<["-"], "Mno"#name>;
9198+
}
9199+
9200+
def Mfixed : Flag<["-"], "Mfixed">, Group<fortran_format_Group>,
9201+
HelpText<"Force fixed-form format Fortran">,
9202+
Flags<[HelpHidden]>;
9203+
def Mfree_on: Flag<["-"], "Mfree">, Group<fortran_format_Group>,
9204+
HelpText<"Enable free-form format for Fortran">,
9205+
Flags<[HelpHidden]>;
9206+
def Mfree_off: Flag<["-"], "Mnofree">, Group<fortran_format_Group>,
9207+
HelpText<"Disable free-form format for Fortran">,
9208+
Flags<[HelpHidden]>;
9209+
def Mfreeform_on: Flag<["-"], "Mfreeform">, Group<fortran_format_Group>,
9210+
HelpText<"Enable free-form format for Fortran">,
9211+
Flags<[HelpHidden]>;
9212+
def Mfreeform_off: Flag<["-"], "Mnofreeform">, Group<fortran_format_Group>,
9213+
HelpText<"Disable free-form format for Fortran">,
9214+
Flags<[HelpHidden]>;
9215+
9216+
def Minfo_EQ : CommaJoined<["-"], "Minfo=">,
9217+
HelpText<"Diagnostic information about successful optimizations">,
9218+
Values<"all,vect,inline">;
9219+
def Minfoall : Flag<["-"], "Minfo">,
9220+
HelpText<"Diagnostic information about all successful optimizations">;
9221+
def Mneginfo_EQ : CommaJoined<["-"], "Mneginfo=">,
9222+
HelpText<"Diagnostic information about missed optimizations">,
9223+
Values<"all,vect,inline">;
9224+
def Mneginfoall : Flag<["-"], "Mneginfo">,
9225+
HelpText<"Diagnostic information about all missed optimizations">;
9226+
9227+
def Mipa: Joined<["-"], "Mipa">, Group<pgi_fortran_Group>;
9228+
def Mstackarrays: Joined<["-"], "Mstack_arrays">, Group<pgi_fortran_Group>;
9229+
def pc: JoinedOrSeparate<["-"], "pc">, Group<pgi_fortran_Group>;
9230+
def Mfprelaxed: Joined<["-"], "Mfprelaxed">, Group<pgi_fortran_Group>;
9231+
def Mnofprelaxed: Joined<["-"], "Mnofprelaxed">, Group<pgi_fortran_Group>;
9232+
defm Mstride0: BooleanMFlag<"stride0">, Group<pgi_fortran_Group>;
9233+
defm Mrecursive: BooleanMFlag<"recursive">, Group<pgi_fortran_Group>;
9234+
defm Mreentrant: BooleanMFlag<"reentrant">, Group<pgi_fortran_Group>;
9235+
defm Mbounds: BooleanMFlag<"bounds">, Group<pgi_fortran_Group>;
9236+
def Mdaz_on: Flag<["-"], "Mdaz">, Group<pgi_fortran_Group>,
9237+
HelpText<"Treat denormalized numbers as zero">;
9238+
def Mdaz_off: Flag<["-"], "Mnodaz">, Group<pgi_fortran_Group>,
9239+
HelpText<"Disable treating denormalized numbers as zero">;
9240+
def Kieee_on : Flag<["-"], "Kieee">, Group<pgi_fortran_Group>,
9241+
HelpText<"Enable IEEE division">;
9242+
def Kieee_off : Flag<["-"], "Knoieee">, Group<pgi_fortran_Group>,
9243+
HelpText<"Disable IEEE division">;
9244+
def Mextend : Flag<["-"], "Mextend">, Group<pgi_fortran_Group>,
9245+
HelpText<"Allow lines up to 132 characters in Fortran sources">;
9246+
def Mpreprocess : Flag<["-"], "Mpreprocess">, Group<pgi_fortran_Group>,
9247+
HelpText<"Preprocess Fortran files">;
9248+
def Mstandard: Flag<["-"], "Mstandard">, Group<pgi_fortran_Group>,
9249+
HelpText<"Check Fortran standard conformance">;
9250+
def Mchkptr: Flag<["-"], "Mchkptr">, Group<pgi_fortran_Group>;
9251+
def Mwritable_constants: Flag<["-"], "Mwritable-constants">, Group<pgi_fortran_Group>,
9252+
HelpText<"Store constants in the writable data segment">;
9253+
defm Minline: BooleanMFlag<"inline">, Group<pgi_fortran_Group>;
9254+
def fma: Flag<["-"], "fma">, Group<pgi_fortran_Group>,
9255+
HelpText<"Enable generation of FMA instructions">;
9256+
def nofma: Flag<["-"], "nofma">, Group<pgi_fortran_Group>,
9257+
HelpText<"Disable generation of FMA instructions">;
9258+
defm Mfma: BooleanMFlag<"fma">, Group<pgi_fortran_Group>,
9259+
HelpText<"Enable generation of FMA instructions">;
9260+
def mp: Flag<["-"], "mp">, Group<pgi_fortran_Group>,
9261+
HelpText<"Enable OpenMP">;
9262+
def nomp: Flag<["-"], "nomp">, Group<pgi_fortran_Group>,
9263+
HelpText<"Do not link with OpenMP library libomp">;
9264+
def Mflushz_on: Flag<["-"], "Mflushz">, Group<pgi_fortran_Group>,
9265+
HelpText<"Set SSE to flush-to-zero mode">;
9266+
def Mflushz_off: Flag<["-"], "Mnoflushz">, Group<pgi_fortran_Group>,
9267+
HelpText<"Disabling setting SSE to flush-to-zero mode">;
9268+
def Msave_on: Flag<["-"], "Msave">, Group<pgi_fortran_Group>,
9269+
HelpText<"Assume all Fortran variables have SAVE attribute">;
9270+
def Msave_off: Flag<["-"], "Mnosave">, Group<pgi_fortran_Group>,
9271+
HelpText<"Assume no Fortran variables have SAVE attribute">;
9272+
def Mcache_align_on: Flag<["-"], "Mcache_align">, Group<pgi_fortran_Group>,
9273+
HelpText<"Align large objects on cache-line boundaries">;
9274+
def Mcache_align_off: Flag<["-"], "Mnocache_align">, Group<pgi_fortran_Group>,
9275+
HelpText<"Disable aligning large objects on cache-line boundaries">;
9276+
def ModuleDir : Separate<["-"], "module">, Group<pgi_fortran_Group>,
9277+
HelpText<"Fortran module path">;
9278+
def Minform_EQ : Joined<["-"], "Minform=">,
9279+
HelpText<"Set error level of messages to display">;
9280+
def Mallocatable_EQ : Joined<["-"], "Mallocatable=">,
9281+
HelpText<"Select semantics for assignments to allocatables (F03 or F95)">;
9282+
def Mbyteswapio: Flag<["-"], "Mbyteswapio">, Group<pgi_fortran_Group>,
9283+
HelpText<"Swap byte-order for unformatted input/output">;
9284+
def byteswapio: Flag<["-"], "byteswapio">, Group<gfortran_Group>,
9285+
HelpText<"Swap byte-order for unformatted input/output">;
9286+
def Mbackslash: Flag<["-"], "Mbackslash">, Group<pgi_fortran_Group>,
9287+
HelpText<"Treat backslash like any other character in character strings">;
9288+
def Mnobackslash: Flag<["-"], "Mnobackslash">, Group<pgi_fortran_Group>,
9289+
HelpText<"Treat backslash as C-style escape character">;
9290+
def staticFlangLibs: Flag<["-"], "static-flang-libs">, Group<flang_rt_Group>,
9291+
HelpText<"Link using static Flang libraries">;
9292+
def noFlangLibs: Flag<["-"], "no-flang-libs">, Group<flang_rt_Group>,
9293+
HelpText<"Do not link against Flang libraries">;
9294+
def r8: Flag<["-"], "r8">, Group<pgi_fortran_Group>,
9295+
HelpText<"Treat REAL as REAL*8">;
9296+
def i8: Flag<["-"], "i8">, Group<pgi_fortran_Group>,
9297+
HelpText<"Treat INTEGER and LOGICAL as INTEGER*8 and LOGICAL*8">;
9298+
def Mnomain: Flag<["-"], "Mnomain">, Group<pgi_fortran_Group>,
9299+
HelpText<"Don't link in Fortran main">;
9300+
def frelaxed_math : Flag<["-"], "frelaxed-math">, Group<pgi_fortran_Group>,
9301+
HelpText<"Use relaxed Math intrinsic functions">;
9302+
def Memit_dwarf_common_blocks_name: Flag<["-"], "Memit-dwarf-common-blocks-name">,
9303+
Group<pgi_fortran_Group>, HelpText<"Emit COMMON blocks name in DWARF">;
9304+
def Munixlogical: Flag<["-"], "Munixlogical">, Group<pgi_fortran_Group>,
9305+
HelpText<"Use unixlogical for all loigical operations">;
9306+
9307+
// Flang internal debug options
9308+
def Mx_EQ : Joined<["-"], "Mx,">, Group<pgi_fortran_Group>;
9309+
def My_EQ : Joined<["-"], "My,">, Group<pgi_fortran_Group>;
9310+
def Hx_EQ : Joined<["-"], "Hx,">, Group<pgi_fortran_Group>;
9311+
def Hy_EQ : Joined<["-"], "Hy,">, Group<pgi_fortran_Group>;
9312+
def Wm_EQ : Joined<["-"], "Wm,">, Group<pgi_fortran_Group>;
9313+
9314+
def Mq_EQ : Joined<["-"], "Mq,">, Group<pgi_fortran_Group>;
9315+
def Hq_EQ : Joined<["-"], "Hq,">, Group<pgi_fortran_Group>;
9316+
def Mqq_EQ : Joined<["-"], "Mqq,">, Group<pgi_fortran_Group>;
9317+
def Hqq_EQ : Joined<["-"], "Hqq,">, Group<pgi_fortran_Group>;
9318+
def Wh_EQ : Joined<["-"], "Wh,">, Group<pgi_fortran_Group>;
9319+
#endif

clang/include/clang/Driver/Phases.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ namespace phases {
1717
enum ID {
1818
Preprocess,
1919
Precompile,
20+
FortranFrontend,
2021
Compile,
2122
Backend,
2223
Assemble,

clang/include/clang/Driver/ToolChain.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ class ToolChain {
159159

160160
mutable std::unique_ptr<Tool> Clang;
161161
mutable std::unique_ptr<Tool> Flang;
162+
mutable std::unique_ptr<Tool> FortranFrontend;
162163
mutable std::unique_ptr<Tool> Assemble;
163164
mutable std::unique_ptr<Tool> Link;
164165
mutable std::unique_ptr<Tool> StaticLibTool;
@@ -169,6 +170,7 @@ class ToolChain {
169170

170171
Tool *getClang() const;
171172
Tool *getFlang() const;
173+
Tool *getFortranFrontend() const;
172174
Tool *getAssemble() const;
173175
Tool *getLink() const;
174176
Tool *getStaticLibTool() const;
@@ -673,6 +675,14 @@ class ToolChain {
673675
AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
674676
llvm::opt::ArgStringList &CC1Args) const;
675677

678+
/// \brief Add the flang arguments for system include paths.
679+
///
680+
/// This routine is responsible for adding the -stdinc argument to
681+
/// include headers and module files from standard system header directories.
682+
virtual void
683+
AddFlangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
684+
llvm::opt::ArgStringList &Flang1Args) const { }
685+
676686
/// Add options that need to be passed to cc1 for this target.
677687
virtual void addClangTargetOptions(const llvm::opt::ArgList &DriverArgs,
678688
llvm::opt::ArgStringList &CC1Args,
@@ -790,6 +800,11 @@ class ToolChain {
790800
virtual void AddHIPRuntimeLibArgs(const llvm::opt::ArgList &Args,
791801
llvm::opt::ArgStringList &CmdArgs) const {}
792802

803+
/// AddFortranStdlibLibArgs - Add the system specific linker arguments to use
804+
/// for the given Fortran runtime library type.
805+
virtual void AddFortranStdlibLibArgs(const llvm::opt::ArgList &Args,
806+
llvm::opt::ArgStringList &CmdArgs) const;
807+
793808
/// Return sanitizers which are available in this toolchain.
794809
virtual SanitizerMask getSupportedSanitizers() const;
795810

clang/include/clang/Driver/Types.def

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,15 @@ TYPE("assembler-with-cpp", Asm, PP_Asm, "S", phases
8888
// modules when Flang needs to emit pre-processed files. Therefore, the
8989
// `PP_TYPE` is set to `PP_Fortran` so that the driver is fine with
9090
// "pre-processing a pre-processed file".
91+
#ifdef ENABLE_CLASSIC_FLANG
92+
TYPE("f77", PP_F_FixedForm, INVALID, "f", phases::FortranFrontend, phases::Backend, phases::Assemble, phases::Link)
93+
TYPE("f77-cpp-input", F_FixedForm, PP_F_FixedForm, "F", phases::FortranFrontend, phases::Backend, phases::Assemble, phases::Link)
94+
TYPE("f95", PP_F_FreeForm, INVALID, "f95", phases::FortranFrontend, phases::Backend, phases::Assemble, phases::Link)
95+
TYPE("f95-cpp-input", F_FreeForm, PP_F_FreeForm, "F95", phases::FortranFrontend, phases::Backend, phases::Assemble, phases::Link)
96+
#else
9197
TYPE("f95", PP_Fortran, PP_Fortran, "i", phases::Preprocess, phases::Compile, phases::Backend, phases::Assemble, phases::Link)
9298
TYPE("f95-cpp-input", Fortran, PP_Fortran, nullptr, phases::Preprocess, phases::Compile, phases::Backend, phases::Assemble, phases::Link)
99+
#endif
93100
TYPE("java", Java, INVALID, nullptr, phases::Compile, phases::Backend, phases::Assemble, phases::Link)
94101

95102
// LLVM IR/LTO types. We define separate types for IR and LTO because LTO

0 commit comments

Comments
 (0)