Skip to content

Commit

Permalink
[Driver] Make supported Clang options visible to Classic Flang
Browse files Browse the repository at this point in the history
Classic Flang accepts some Clang options that LLVM Flang (F18) does not.
The Visibility of such options are modified to include "FlangOption".
  • Loading branch information
bryanpkc committed Apr 11, 2024
1 parent 1452f34 commit 96a9ea5
Showing 1 changed file with 77 additions and 22 deletions.
99 changes: 77 additions & 22 deletions clang/include/clang/Driver/Options.td
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,11 @@ def ccc_gcc_name : Separate<["-"], "ccc-gcc-name">, InternalDriverOpt,

class InternalDebugOpt : Group<internal_debug_Group>,
Flags<[NoXarchOption, HelpHidden]>,
#ifdef ENABLE_CLASSIC_FLANG
Visibility<[ClangOption, CLOption, DXCOption, FlangOption]>;
#else
Visibility<[ClangOption, CLOption, DXCOption]>;
#endif
def ccc_install_dir : Separate<["-"], "ccc-install-dir">, InternalDebugOpt,
HelpText<"Simulate installation in the given directory">;
def ccc_print_phases : Flag<["-"], "ccc-print-phases">,
Expand Down Expand Up @@ -765,6 +769,9 @@ def _DASH_DASH : Option<["--"], "", KIND_REMAINING_ARGS>,
def A : JoinedOrSeparate<["-"], "A">, Flags<[RenderJoined]>,
Group<gfortran_Group>;
def B : JoinedOrSeparate<["-"], "B">, MetaVarName<"<prefix>">,
#ifdef ENABLE_CLASSIC_FLANG
Visibility<[ClangOption, FlangOption]>,
#endif
HelpText<"Search $prefix$file for executables, libraries, and data files. "
"If $prefix is a directory, search $prefix/$file">;
def gcc_install_dir_EQ : Joined<["--"], "gcc-install-dir=">,
Expand Down Expand Up @@ -1450,6 +1457,7 @@ def emit_ast : Flag<["-"], "emit-ast">,
HelpText<"Emit Clang AST files for source inputs">;
#ifdef ENABLE_CLASSIC_FLANG
def emit_flang_llvm : Flag<["-"], "emit-flang-llvm">,
Visibility<[FlangOption]>,
HelpText<"Emit Flang LLVM files for source inputs">;
#endif
def emit_llvm : Flag<["-"], "emit-llvm">,
Expand Down Expand Up @@ -3365,6 +3373,9 @@ def fopenmp : Flag<["-"], "fopenmp">, Group<f_Group>,
Visibility<[ClangOption, CC1Option, FlangOption, FC1Option]>,
HelpText<"Parse OpenMP pragmas and generate parallel code.">;
def fno_openmp : Flag<["-"], "fno-openmp">, Group<f_Group>,
#ifdef ENABLE_CLASSIC_FLANG
Visibility<[ClangOption, FlangOption]>,
#endif
Flags<[NoArgumentUnused]>;
def fopenmp_version_EQ : Joined<["-"], "fopenmp-version=">, Group<f_Group>,
Flags<[NoArgumentUnused]>,
Expand Down Expand Up @@ -3497,6 +3508,9 @@ defm openmp_optimistic_collapse : BoolFOption<"openmp-optimistic-collapse",
PosFlag<SetTrue, [], [ClangOption, CC1Option]>,
NegFlag<SetFalse>, BothFlags<[NoArgumentUnused, HelpHidden], []>>;
def static_openmp: Flag<["-"], "static-openmp">,
#ifdef ENABLE_CLASSIC_FLANG
Visibility<[ClangOption, FlangOption]>,
#endif
HelpText<"Use the static host OpenMP runtime while linking.">;
def fopenmp_new_driver : Flag<["-"], "fopenmp-new-driver">, Flags<[HelpHidden]>,
HelpText<"Use the new driver for OpenMP offloading.">;
Expand Down Expand Up @@ -4145,15 +4159,31 @@ def gdbx : Flag<["-"], "gdbx">, Group<gTune_Group>;
// Equivalent to our default dwarf version. Forces usual dwarf emission when
// CodeView is enabled.
def gdwarf : Flag<["-"], "gdwarf">, Group<g_Group>,
#ifdef ENABLE_CLASSIC_FLANG
Visibility<[ClangOption, CLOption, DXCOption, FlangOption]>,
#else
Visibility<[ClangOption, CLOption, DXCOption]>,
#endif
HelpText<"Generate source-level debug information with the default dwarf version">;
def gdwarf_2 : Flag<["-"], "gdwarf-2">, Group<g_Group>,
#ifdef ENABLE_CLASSIC_FLANG
Visibility<[ClangOption, FlangOption]>,
#endif
HelpText<"Generate source-level debug information with dwarf version 2">;
def gdwarf_3 : Flag<["-"], "gdwarf-3">, Group<g_Group>,
#ifdef ENABLE_CLASSIC_FLANG
Visibility<[ClangOption, FlangOption]>,
#endif
HelpText<"Generate source-level debug information with dwarf version 3">;
def gdwarf_4 : Flag<["-"], "gdwarf-4">, Group<g_Group>,
#ifdef ENABLE_CLASSIC_FLANG
Visibility<[ClangOption, FlangOption]>,
#endif
HelpText<"Generate source-level debug information with dwarf version 4">;
def gdwarf_5 : Flag<["-"], "gdwarf-5">, Group<g_Group>,
#ifdef ENABLE_CLASSIC_FLANG
Visibility<[ClangOption, FlangOption]>,
#endif
HelpText<"Generate source-level debug information with dwarf version 5">;
def gdwarf64 : Flag<["-"], "gdwarf64">, Group<g_Group>,
Visibility<[ClangOption, CC1Option, CC1AsOption]>,
Expand Down Expand Up @@ -4233,9 +4263,16 @@ def gno_simple_template_names : Flag<["-"], "gno-simple-template-names">,
def ggnu_pubnames : Flag<["-"], "ggnu-pubnames">, Group<g_flags_Group>,
Visibility<[ClangOption, CC1Option]>;
def gno_gnu_pubnames : Flag<["-"], "gno-gnu-pubnames">, Group<g_flags_Group>;
#ifdef ENABLE_CLASSIC_FLANG
def gpubnames : Flag<["-"], "gpubnames">, Group<g_flags_Group>,
Visibility<[ClangOption, CC1Option, FlangOption]>;
def gno_pubnames : Flag<["-"], "gno-pubnames">, Group<g_flags_Group>,
Visibility<[ClangOption, CC1Option, FlangOption]>;
#else
def gpubnames : Flag<["-"], "gpubnames">, Group<g_flags_Group>,
Visibility<[ClangOption, CC1Option]>;
def gno_pubnames : Flag<["-"], "gno-pubnames">, Group<g_flags_Group>;
#endif
def gdwarf_aranges : Flag<["-"], "gdwarf-aranges">, Group<g_flags_Group>;
def gmodules : Flag <["-"], "gmodules">, Group<gN_Group>,
HelpText<"Generate debug info with external references to clang modules"
Expand Down Expand Up @@ -5264,7 +5301,12 @@ def nostdincxx : Flag<["-"], "nostdinc++">, Visibility<[ClangOption, CC1Option]>
Group<IncludePath_Group>,
HelpText<"Disable standard #include directories for the C++ standard library">,
MarshallingInfoNegativeFlag<HeaderSearchOpts<"UseStandardCXXIncludes">>;
#ifdef ENABLE_CLASSIC_FLANG
def nostdlib : Flag<["-"], "nostdlib">, Group<Link_Group>,
Visibility<[ClangOption, FlangOption]>;
#else
def nostdlib : Flag<["-"], "nostdlib">, Group<Link_Group>;
#endif
def nostdlibxx : Flag<["-"], "nostdlib++">;
def object : Flag<["-"], "object">;
def o : JoinedOrSeparate<["-"], "o">,
Expand Down Expand Up @@ -5492,7 +5534,11 @@ def : Flag<["-"], "mtune=help">, Alias<print_supported_cpus>;
def time : Flag<["-"], "time">,
HelpText<"Time individual commands">;
def traditional_cpp : Flag<["-", "--"], "traditional-cpp">,
#ifdef ENABLE_CLASSIC_FLANG
Visibility<[ClangOption, CC1Option, FlangOption]>,
#else
Visibility<[ClangOption, CC1Option]>,
#endif
HelpText<"Enable some traditional CPP emulation">,
MarshallingInfoFlag<LangOpts<"TraditionalCPP">>;
def traditional : Flag<["-", "--"], "traditional">;
Expand Down Expand Up @@ -5569,7 +5615,12 @@ def fno_integrated_objemitter : Flag<["-"], "fno-integrated-objemitter">,
Group<f_Group>,
HelpText<"Use external machine object code emitter.">;

#ifdef ENABLE_CLASSIC_FLANG
def : Flag<["-"], "integrated-as">, Alias<fintegrated_as>,
Visibility<[ClangOption, CC1Option, FlangOption]>;
#else
def : Flag<["-"], "integrated-as">, Alias<fintegrated_as>;
#endif
def : Flag<["-"], "no-integrated-as">, Alias<fno_integrated_as>,
Visibility<[ClangOption, CC1Option, FlangOption]>;

Expand Down Expand Up @@ -6479,7 +6530,7 @@ defm loop_versioning : BoolOptionWithoutMarshalling<"f", "version-loops-for-stri

#ifdef ENABLE_CLASSIC_FLANG
def J : JoinedOrSeparate<["-"], "J">,
Flags<[RenderJoined]>,
Flags<[RenderJoined]>, Visibility<[FlangOption, FC1Option]>,
Group<gfortran_Group>;
#else
def J : JoinedOrSeparate<["-"], "J">,
Expand Down Expand Up @@ -8539,6 +8590,27 @@ def fcgl : DXCFlag<"fcgl">, Alias<emit_pristine_llvm>;
def enable_16bit_types : DXCFlag<"enable-16bit-types">, Alias<fnative_half_type>,
HelpText<"Enable 16-bit types and disable min precision types."
"Available in HLSL 2018 and shader model 6.2.">;
def hlsl_entrypoint : Option<["-"], "hlsl-entry", KIND_SEPARATE>,
Group<dxc_Group>,
Visibility<[ClangOption, CC1Option]>,
MarshallingInfoString<TargetOpts<"HLSLEntry">, "\"main\"">,
HelpText<"Entry point name for hlsl">;
def dxc_entrypoint : Option<["--", "/", "-"], "E", KIND_JOINED_OR_SEPARATE>,
Group<dxc_Group>,
Visibility<[DXCOption]>,
HelpText<"Entry point name">;
def dxc_validator_path_EQ : Joined<["--"], "dxv-path=">, Group<dxc_Group>,
HelpText<"DXIL validator installation path">;
def dxc_disable_validation : DXCFlag<"Vd">,
HelpText<"Disable validation">;
def : Option<["/", "-"], "Qembed_debug", KIND_FLAG>, Group<dxc_Group>,
Flags<[Ignored]>, Visibility<[DXCOption]>,
HelpText<"Embed PDB in shader container (ignored)">;
def spirv : DXCFlag<"spirv">,
HelpText<"Generate SPIR-V code">;
def fspv_target_env_EQ : Joined<["-"], "fspv-target-env=">, Group<dxc_Group>,
HelpText<"Specify the target environment">,
Values<"vulkan1.2, vulkan1.3">;

#ifdef ENABLE_CLASSIC_FLANG
// Classic Flang options that we recognize in the driver and pass along when
Expand All @@ -8558,6 +8630,8 @@ multiclass BooleanMFlag<string name> {
def _off : Flag<["-"], "Mno"#name>;
}

let Visibility = [FlangOption] in {

def Mfixed : Flag<["-"], "Mfixed">, Group<fortran_format_Group>,
HelpText<"Force fixed-form format Fortran">,
Flags<[HelpHidden]>;
Expand Down Expand Up @@ -8677,25 +8751,6 @@ def Hq_EQ : Joined<["-"], "Hq,">, Group<pgi_fortran_Group>;
def Mqq_EQ : Joined<["-"], "Mqq,">, Group<pgi_fortran_Group>;
def Hqq_EQ : Joined<["-"], "Hqq,">, Group<pgi_fortran_Group>;
def Wh_EQ : Joined<["-"], "Wh,">, Group<pgi_fortran_Group>;

} // let Visibility = [FlangOption]
#endif
def hlsl_entrypoint : Option<["-"], "hlsl-entry", KIND_SEPARATE>,
Group<dxc_Group>,
Visibility<[ClangOption, CC1Option]>,
MarshallingInfoString<TargetOpts<"HLSLEntry">, "\"main\"">,
HelpText<"Entry point name for hlsl">;
def dxc_entrypoint : Option<["--", "/", "-"], "E", KIND_JOINED_OR_SEPARATE>,
Group<dxc_Group>,
Visibility<[DXCOption]>,
HelpText<"Entry point name">;
def dxc_validator_path_EQ : Joined<["--"], "dxv-path=">, Group<dxc_Group>,
HelpText<"DXIL validator installation path">;
def dxc_disable_validation : DXCFlag<"Vd">,
HelpText<"Disable validation">;
def : Option<["/", "-"], "Qembed_debug", KIND_FLAG>, Group<dxc_Group>,
Flags<[Ignored]>, Visibility<[DXCOption]>,
HelpText<"Embed PDB in shader container (ignored)">;
def spirv : DXCFlag<"spirv">,
HelpText<"Generate SPIR-V code">;
def fspv_target_env_EQ : Joined<["-"], "fspv-target-env=">, Group<dxc_Group>,
HelpText<"Specify the target environment">,
Values<"vulkan1.2, vulkan1.3">;

0 comments on commit 96a9ea5

Please sign in to comment.