Skip to content

Commit 9b92884

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
1 parent da8b348 commit 9b92884

File tree

75 files changed

+2878
-108
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

+2878
-108
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
@@ -152,6 +152,10 @@ def err_drv_invalid_linker_name : Error<
152152
"invalid linker name in argument '%0'">;
153153
def err_drv_invalid_rtlib_name : Error<
154154
"invalid runtime library name in argument '%0'">;
155+
def err_drv_invalid_allocatable_mode : Error<
156+
"invalid semantic mode for assignments to allocatables in argument '%0'">;
157+
def err_drv_unsupported_fixed_line_length : Error<
158+
"unsupported fixed-format line length in argument '%0'">;
155159
def err_drv_unsupported_rtlib_for_platform : Error<
156160
"unsupported runtime library '%0' for platform '%1'">;
157161
def err_drv_invalid_unwindlib_name : Error<
@@ -380,6 +384,8 @@ def err_drv_small_columns : Error<
380384
def warn_drv_fraw_string_literals_in_cxx11 : Warning<
381385
"ignoring '-f%select{no-|}0raw-string-literals', which is only valid for C and C++ standards before C++11">,
382386
InGroup<UnusedCommandLineArgument>;
387+
def err_drv_clang_unsupported_minfo_arg : Error<
388+
"'%0' option does not support '%1' value">;
383389

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

clang/include/clang/Basic/MacroBuilder.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,10 @@ 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".
29-
void defineMacro(const Twine &Name, const Twine &Value = "1") {
30+
virtual void defineMacro(const Twine &Name, const Twine &Value = "1") {
3031
Out << "#define " << Name << ' ' << Value << '\n';
3132
}
3233

clang/include/clang/Basic/Sanitizers.def

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,8 @@ SANITIZER("signed-integer-overflow", SignedIntegerOverflow)
110110
SANITIZER("unreachable", Unreachable)
111111
SANITIZER("vla-bound", VLABound)
112112
SANITIZER("vptr", Vptr)
113+
// fortran contiguous pointer checks
114+
SANITIZER("discontiguous", Discontiguous)
113115

114116
// IntegerSanitizer
115117
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,
@@ -470,6 +471,16 @@ class MigrateJobAction : public JobAction {
470471
}
471472
};
472473

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

clang/include/clang/Driver/Options.td

Lines changed: 181 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3348,10 +3348,17 @@ def fno_experimental_isel : Flag<["-"], "fno-experimental-isel">, Group<f_clang_
33483348
def fveclib : Joined<["-"], "fveclib=">, Group<f_Group>,
33493349
Visibility<[ClangOption, CC1Option, FlangOption, FC1Option]>,
33503350
HelpText<"Use the given vector functions library">,
3351+
#ifdef ENABLE_CLASSIC_FLANG
3352+
Values<"Accelerate,libmvec,MASSV,PGMATH,SVML,SLEEF,Darwin_libsystem_m,ArmPL,AMDLIBM,none">,
3353+
NormalizedValuesScope<"llvm::driver::VectorLibrary">,
3354+
NormalizedValues<["Accelerate", "LIBMVEC", "MASSV", "PGMATH", "SVML", "SLEEF",
3355+
"Darwin_libsystem_m", "ArmPL", "AMDLIBM", "NoLibrary"]>,
3356+
#else
33513357
Values<"Accelerate,libmvec,MASSV,SVML,SLEEF,Darwin_libsystem_m,ArmPL,AMDLIBM,none">,
33523358
NormalizedValuesScope<"llvm::driver::VectorLibrary">,
33533359
NormalizedValues<["Accelerate", "LIBMVEC", "MASSV", "SVML", "SLEEF",
33543360
"Darwin_libsystem_m", "ArmPL", "AMDLIBM", "NoLibrary"]>,
3361+
#endif
33553362
MarshallingInfoEnum<CodeGenOpts<"VecLib">, "NoLibrary">;
33563363
def fno_lax_vector_conversions : Flag<["-"], "fno-lax-vector-conversions">, Group<f_Group>,
33573364
Alias<flax_vector_conversions_EQ>, AliasArgs<["none"]>;
@@ -6683,6 +6690,20 @@ def module_dir : JoinedOrSeparate<["-"], "module-dir">, MetaVarName<"<dir>">,
66836690
It is also added to the list of directories to be searched by an USE statement.
66846691
The default is the current directory.}]>;
66856692

6693+
#ifdef ENABLE_CLASSIC_FLANG
6694+
// Define a group for Fortran source format options.
6695+
def fortran_format_Group : OptionGroup<"Fortran format Group">, Group<gfortran_Group>;
6696+
def ffixed_form : Flag<["-"], "ffixed-form">, Group<fortran_format_Group>,
6697+
HelpText<"Process source files in fixed form">;
6698+
def fno_fixed_form : Flag<["-"], "fno-fixed-form">, Group<fortran_format_Group>,
6699+
HelpText<"Disable fixed-form format for Fortran">;
6700+
def ffree_form : Flag<["-"], "ffree-form">, Group<fortran_format_Group>,
6701+
HelpText<"Process source files in free form">;
6702+
def fno_free_form : Flag<["-"], "fno-free-form">, Group<fortran_format_Group>,
6703+
HelpText<"Disable free-form format for Fortran">;
6704+
def ffixed_line_length_VALUE : Joined<["-"], "ffixed-line-length-">, Group<f_Group>,
6705+
HelpText<"Set line length in fixed-form format Fortran, current supporting only 72 and 132 characters">;
6706+
#else
66866707
def ffixed_form : Flag<["-"], "ffixed-form">, Group<f_Group>,
66876708
HelpText<"Process source files in fixed form">;
66886709
def ffree_form : Flag<["-"], "ffree-form">, Group<f_Group>,
@@ -6692,24 +6713,36 @@ def ffixed_line_length_EQ : Joined<["-"], "ffixed-line-length=">, Group<f_Group>
66926713
DocBrief<[{Set column after which characters are ignored in typical fixed-form lines in the source
66936714
file}]>;
66946715
def ffixed_line_length_VALUE : Joined<["-"], "ffixed-line-length-">, Group<f_Group>, Alias<ffixed_line_length_EQ>;
6716+
#endif
66956717
def fconvert_EQ : Joined<["-"], "fconvert=">, Group<f_Group>,
66966718
HelpText<"Set endian conversion of data for unformatted files">;
66976719
def fdefault_double_8 : Flag<["-"],"fdefault-double-8">, Group<f_Group>,
66986720
HelpText<"Set the default double precision kind to an 8 byte wide type">;
6721+
#ifdef ENABLE_CLASSIC_FLANG
6722+
def fno_default_integer_8 : Flag<["-"], "fno-default-integer-8">, Group<f_Group>;
6723+
#endif
66996724
def fdefault_integer_8 : Flag<["-"],"fdefault-integer-8">, Group<f_Group>,
67006725
HelpText<"Set the default integer and logical kind to an 8 byte wide type">;
67016726
def fdefault_real_8 : Flag<["-"],"fdefault-real-8">, Group<f_Group>,
67026727
HelpText<"Set the default real kind to an 8 byte wide type">;
6728+
#ifdef ENABLE_CLASSIC_FLANG
6729+
def fno_default_real_8 : Flag<["-"], "fno-default-real-8">, Group<f_Group>;
6730+
#endif
67036731
def flarge_sizes : Flag<["-"],"flarge-sizes">, Group<f_Group>,
67046732
HelpText<"Use INTEGER(KIND=8) for the result type in size-related intrinsics">;
6705-
67066733
def falternative_parameter_statement : Flag<["-"], "falternative-parameter-statement">, Group<f_Group>,
67076734
HelpText<"Enable the old style PARAMETER statement">;
67086735
def fintrinsic_modules_path : Separate<["-"], "fintrinsic-modules-path">, Group<f_Group>, MetaVarName<"<dir>">,
67096736
HelpText<"Specify where to find the compiled intrinsic modules">,
67106737
DocBrief<[{This option specifies the location of pre-compiled intrinsic modules,
67116738
if they are not in the default location expected by the compiler.}]>;
6712-
6739+
#ifdef ENABLE_CLASSIC_FLANG
6740+
def fbackslash : Flag<["-"], "fbackslash">, Group<gfortran_Group>,
6741+
HelpText<"Specify that backslash in string introduces an escape character">,
6742+
DocBrief<[{Change the interpretation of backslashes in string literals from
6743+
a single backslash character to "C-style" escape characters.}]>;
6744+
def fno_backslash : Flag<["-"], "fno-backslash">, Group<gfortran_Group>;
6745+
#else
67136746
defm backslash : OptInFC1FFlag<"backslash", "Specify that backslash in string introduces an escape character">;
67146747
defm xor_operator : OptInFC1FFlag<"xor-operator", "Enable .XOR. as a synonym of .NEQV.">;
67156748
defm logical_abbreviations : OptInFC1FFlag<"logical-abbreviations", "Enable logical abbreviations">;
@@ -6721,6 +6754,7 @@ defm ppc_native_vec_elem_order: BoolOptionWithoutMarshalling<"f", "ppc-native-ve
67216754

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

67256759
defm stack_arrays : BoolOptionWithoutMarshalling<"f", "stack-arrays",
67266760
PosFlag<SetTrue, [], [ClangOption], "Attempt to allocate array temporaries on the stack, no matter their size">,
@@ -6733,10 +6767,16 @@ def fhermetic_module_files : Flag<["-"], "fhermetic-module-files">, Group<f_Grou
67336767
HelpText<"Emit hermetic module files (no nested USE association)">;
67346768
} // let Visibility = [FC1Option, FlangOption]
67356769

6770+
#ifdef ENABLE_CLASSIC_FLANG
6771+
def J : JoinedOrSeparate<["-"], "J">,
6772+
Flags<[RenderJoined]>,
6773+
Group<gfortran_Group>;
6774+
#else
67366775
def J : JoinedOrSeparate<["-"], "J">,
67376776
Flags<[RenderJoined]>, Visibility<[FlangOption, FC1Option]>,
67386777
Group<gfortran_Group>,
67396778
Alias<module_dir>;
6779+
#endif
67406780

67416781
//===----------------------------------------------------------------------===//
67426782
// FC1 Options
@@ -8819,6 +8859,145 @@ def fcgl : DXCFlag<"fcgl">, Alias<emit_pristine_llvm>;
88198859
def enable_16bit_types : DXCFlag<"enable-16bit-types">, Alias<fnative_half_type>,
88208860
HelpText<"Enable 16-bit types and disable min precision types."
88218861
"Available in HLSL 2018 and shader model 6.2.">;
8862+
8863+
#ifdef ENABLE_CLASSIC_FLANG
8864+
// gfortran options that we recognize in the driver and pass along when
8865+
// invoking GCC to compile Fortran code.
8866+
def flang_rt_Group : OptionGroup<"Flang runtime library Group">;
8867+
def pgi_fortran_Group : OptionGroup<"PGI Fortran compatibility Group">,
8868+
Flags<[HelpHidden]>;
8869+
8870+
// Classic Flang-specific options
8871+
multiclass BooleanKFlag<string name> {
8872+
def _on : Flag<["-"], "K"#name>;
8873+
def _off : Flag<["-"], "Kno"#name>;
8874+
}
8875+
8876+
multiclass BooleanMFlag<string name> {
8877+
def _on : Flag<["-"], "M"#name>;
8878+
def _off : Flag<["-"], "Mno"#name>;
8879+
}
8880+
8881+
def Mfixed : Flag<["-"], "Mfixed">, Group<fortran_format_Group>,
8882+
HelpText<"Force fixed-form format Fortran">,
8883+
Flags<[HelpHidden]>;
8884+
def Mfree_on: Flag<["-"], "Mfree">, Group<fortran_format_Group>,
8885+
HelpText<"Enable free-form format for Fortran">,
8886+
Flags<[HelpHidden]>;
8887+
def Mfree_off: Flag<["-"], "Mnofree">, Group<fortran_format_Group>,
8888+
HelpText<"Disable free-form format for Fortran">,
8889+
Flags<[HelpHidden]>;
8890+
def Mfreeform_on: Flag<["-"], "Mfreeform">, Group<fortran_format_Group>,
8891+
HelpText<"Enable free-form format for Fortran">,
8892+
Flags<[HelpHidden]>;
8893+
def Mfreeform_off: Flag<["-"], "Mnofreeform">, Group<fortran_format_Group>,
8894+
HelpText<"Disable free-form format for Fortran">,
8895+
Flags<[HelpHidden]>;
8896+
8897+
def Minfo_EQ : CommaJoined<["-"], "Minfo=">,
8898+
HelpText<"Diagnostic information about successful optimizations">,
8899+
Values<"all,vect,inline">;
8900+
def Minfoall : Flag<["-"], "Minfo">,
8901+
HelpText<"Diagnostic information about all successful optimizations">;
8902+
def Mneginfo_EQ : CommaJoined<["-"], "Mneginfo=">,
8903+
HelpText<"Diagnostic information about missed optimizations">,
8904+
Values<"all,vect,inline">;
8905+
def Mneginfoall : Flag<["-"], "Mneginfo">,
8906+
HelpText<"Diagnostic information about all missed optimizations">;
8907+
8908+
def Mipa: Joined<["-"], "Mipa">, Group<pgi_fortran_Group>;
8909+
def Mstackarrays: Joined<["-"], "Mstack_arrays">, Group<pgi_fortran_Group>;
8910+
def pc: JoinedOrSeparate<["-"], "pc">, Group<pgi_fortran_Group>;
8911+
def Mfprelaxed: Joined<["-"], "Mfprelaxed">, Group<pgi_fortran_Group>;
8912+
def Mnofprelaxed: Joined<["-"], "Mnofprelaxed">, Group<pgi_fortran_Group>;
8913+
defm Mstride0: BooleanMFlag<"stride0">, Group<pgi_fortran_Group>;
8914+
defm Mrecursive: BooleanMFlag<"recursive">, Group<pgi_fortran_Group>;
8915+
defm Mreentrant: BooleanMFlag<"reentrant">, Group<pgi_fortran_Group>;
8916+
defm Mbounds: BooleanMFlag<"bounds">, Group<pgi_fortran_Group>;
8917+
def Mdaz_on: Flag<["-"], "Mdaz">, Group<pgi_fortran_Group>,
8918+
HelpText<"Treat denormalized numbers as zero">;
8919+
def Mdaz_off: Flag<["-"], "Mnodaz">, Group<pgi_fortran_Group>,
8920+
HelpText<"Disable treating denormalized numbers as zero">;
8921+
def Kieee_on : Flag<["-"], "Kieee">, Group<pgi_fortran_Group>,
8922+
HelpText<"Enable IEEE division">;
8923+
def Kieee_off : Flag<["-"], "Knoieee">, Group<pgi_fortran_Group>,
8924+
HelpText<"Disable IEEE division">;
8925+
def Mextend : Flag<["-"], "Mextend">, Group<pgi_fortran_Group>,
8926+
HelpText<"Allow lines up to 132 characters in Fortran sources">;
8927+
def Mpreprocess : Flag<["-"], "Mpreprocess">, Group<pgi_fortran_Group>,
8928+
HelpText<"Preprocess Fortran files">;
8929+
def Mstandard: Flag<["-"], "Mstandard">, Group<pgi_fortran_Group>,
8930+
HelpText<"Check Fortran standard conformance">;
8931+
def Mchkptr: Flag<["-"], "Mchkptr">, Group<pgi_fortran_Group>;
8932+
def Mwritable_constants: Flag<["-"], "Mwritable-constants">, Group<pgi_fortran_Group>,
8933+
HelpText<"Store constants in the writable data segment">;
8934+
defm Minline: BooleanMFlag<"inline">, Group<pgi_fortran_Group>;
8935+
def fma: Flag<["-"], "fma">, Group<pgi_fortran_Group>,
8936+
HelpText<"Enable generation of FMA instructions">;
8937+
def nofma: Flag<["-"], "nofma">, Group<pgi_fortran_Group>,
8938+
HelpText<"Disable generation of FMA instructions">;
8939+
defm Mfma: BooleanMFlag<"fma">, Group<pgi_fortran_Group>,
8940+
HelpText<"Enable generation of FMA instructions">;
8941+
def mp: Flag<["-"], "mp">, Group<pgi_fortran_Group>,
8942+
HelpText<"Enable OpenMP">;
8943+
def nomp: Flag<["-"], "nomp">, Group<pgi_fortran_Group>,
8944+
HelpText<"Do not link with OpenMP library libomp">;
8945+
def Mflushz_on: Flag<["-"], "Mflushz">, Group<pgi_fortran_Group>,
8946+
HelpText<"Set SSE to flush-to-zero mode">;
8947+
def Mflushz_off: Flag<["-"], "Mnoflushz">, Group<pgi_fortran_Group>,
8948+
HelpText<"Disabling setting SSE to flush-to-zero mode">;
8949+
def Msave_on: Flag<["-"], "Msave">, Group<pgi_fortran_Group>,
8950+
HelpText<"Assume all Fortran variables have SAVE attribute">;
8951+
def Msave_off: Flag<["-"], "Mnosave">, Group<pgi_fortran_Group>,
8952+
HelpText<"Assume no Fortran variables have SAVE attribute">;
8953+
def Mcache_align_on: Flag<["-"], "Mcache_align">, Group<pgi_fortran_Group>,
8954+
HelpText<"Align large objects on cache-line boundaries">;
8955+
def Mcache_align_off: Flag<["-"], "Mnocache_align">, Group<pgi_fortran_Group>,
8956+
HelpText<"Disable aligning large objects on cache-line boundaries">;
8957+
def ModuleDir : Separate<["-"], "module">, Group<pgi_fortran_Group>,
8958+
HelpText<"Fortran module path">;
8959+
def Minform_EQ : Joined<["-"], "Minform=">,
8960+
HelpText<"Set error level of messages to display">;
8961+
def Mallocatable_EQ : Joined<["-"], "Mallocatable=">,
8962+
HelpText<"Select semantics for assignments to allocatables (F03 or F95)">;
8963+
def Mbyteswapio: Flag<["-"], "Mbyteswapio">, Group<pgi_fortran_Group>,
8964+
HelpText<"Swap byte-order for unformatted input/output">;
8965+
def byteswapio: Flag<["-"], "byteswapio">, Group<gfortran_Group>,
8966+
HelpText<"Swap byte-order for unformatted input/output">;
8967+
def Mbackslash: Flag<["-"], "Mbackslash">, Group<pgi_fortran_Group>,
8968+
HelpText<"Treat backslash like any other character in character strings">;
8969+
def Mnobackslash: Flag<["-"], "Mnobackslash">, Group<pgi_fortran_Group>,
8970+
HelpText<"Treat backslash as C-style escape character">;
8971+
def staticFlangLibs: Flag<["-"], "static-flang-libs">, Group<flang_rt_Group>,
8972+
HelpText<"Link using static Flang libraries">;
8973+
def noFlangLibs: Flag<["-"], "no-flang-libs">, Group<flang_rt_Group>,
8974+
HelpText<"Do not link against Flang libraries">;
8975+
def r8: Flag<["-"], "r8">, Group<pgi_fortran_Group>,
8976+
HelpText<"Treat REAL as REAL*8">;
8977+
def i8: Flag<["-"], "i8">, Group<pgi_fortran_Group>,
8978+
HelpText<"Treat INTEGER and LOGICAL as INTEGER*8 and LOGICAL*8">;
8979+
def Mnomain: Flag<["-"], "Mnomain">, Group<pgi_fortran_Group>,
8980+
HelpText<"Don't link in Fortran main">;
8981+
def frelaxed_math : Flag<["-"], "frelaxed-math">, Group<pgi_fortran_Group>,
8982+
HelpText<"Use relaxed Math intrinsic functions">;
8983+
def Memit_dwarf_common_blocks_name: Flag<["-"], "Memit-dwarf-common-blocks-name">,
8984+
Group<pgi_fortran_Group>, HelpText<"Emit COMMON blocks name in DWARF">;
8985+
def Munixlogical: Flag<["-"], "Munixlogical">, Group<pgi_fortran_Group>,
8986+
HelpText<"Use unixlogical for all loigical operations">;
8987+
8988+
// Flang internal debug options
8989+
def Mx_EQ : Joined<["-"], "Mx,">, Group<pgi_fortran_Group>;
8990+
def My_EQ : Joined<["-"], "My,">, Group<pgi_fortran_Group>;
8991+
def Hx_EQ : Joined<["-"], "Hx,">, Group<pgi_fortran_Group>;
8992+
def Hy_EQ : Joined<["-"], "Hy,">, Group<pgi_fortran_Group>;
8993+
def Wm_EQ : Joined<["-"], "Wm,">, Group<pgi_fortran_Group>;
8994+
8995+
def Mq_EQ : Joined<["-"], "Mq,">, Group<pgi_fortran_Group>;
8996+
def Hq_EQ : Joined<["-"], "Hq,">, Group<pgi_fortran_Group>;
8997+
def Mqq_EQ : Joined<["-"], "Mqq,">, Group<pgi_fortran_Group>;
8998+
def Hqq_EQ : Joined<["-"], "Hqq,">, Group<pgi_fortran_Group>;
8999+
def Wh_EQ : Joined<["-"], "Wh,">, Group<pgi_fortran_Group>;
9000+
#endif
88229001
def hlsl_entrypoint : Option<["-"], "hlsl-entry", KIND_SEPARATE>,
88239002
Group<dxc_Group>,
88249003
Visibility<[ClangOption, CC1Option]>,

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;
@@ -674,6 +676,14 @@ class ToolChain {
674676
AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
675677
llvm::opt::ArgStringList &CC1Args) const;
676678

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

793+
/// AddFortranStdlibLibArgs - Add the system specific linker arguments to use
794+
/// for the given Fortran runtime library type.
795+
virtual void AddFortranStdlibLibArgs(const llvm::opt::ArgList &Args,
796+
llvm::opt::ArgStringList &CmdArgs) const;
797+
783798
/// Return sanitizers which are available in this toolchain.
784799
virtual SanitizerMask getSupportedSanitizers() const;
785800

clang/include/clang/Driver/Types.def

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,15 @@ TYPE("c++-module-cpp-output", PP_CXXModule, INVALID, "iim", phases
7979
TYPE("ada", Ada, INVALID, nullptr, phases::Compile, phases::Backend, phases::Assemble, phases::Link)
8080
TYPE("assembler", PP_Asm, INVALID, "s", phases::Assemble, phases::Link)
8181
TYPE("assembler-with-cpp", Asm, PP_Asm, "S", phases::Preprocess, phases::Assemble, phases::Link)
82+
#ifdef ENABLE_CLASSIC_FLANG
83+
TYPE("f77", PP_F_FixedForm, INVALID, "f", phases::FortranFrontend, phases::Backend, phases::Assemble, phases::Link)
84+
TYPE("f77-cpp-input", F_FixedForm, PP_F_FixedForm, "F", phases::FortranFrontend, phases::Backend, phases::Assemble, phases::Link)
85+
TYPE("f95", PP_F_FreeForm, INVALID, "f95", phases::FortranFrontend, phases::Backend, phases::Assemble, phases::Link)
86+
TYPE("f95-cpp-input", F_FreeForm, PP_F_FreeForm, "F95", phases::FortranFrontend, phases::Backend, phases::Assemble, phases::Link)
87+
#else
8288
TYPE("f95", PP_Fortran, INVALID, "i", phases::Compile, phases::Backend, phases::Assemble, phases::Link)
8389
TYPE("f95-cpp-input", Fortran, PP_Fortran, nullptr, phases::Preprocess, phases::Compile, phases::Backend, phases::Assemble, phases::Link)
90+
#endif
8491
TYPE("java", Java, INVALID, nullptr, phases::Compile, phases::Backend, phases::Assemble, phases::Link)
8592

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

0 commit comments

Comments
 (0)