From fa2b19ff0de2edb3166331d8ffa1f9ad5ea4eafe Mon Sep 17 00:00:00 2001 From: Kiran Chandramohan Date: Thu, 30 Apr 2026 18:50:20 +0100 Subject: [PATCH] [Flang][Driver] NFC: Move Flang/Fortran only options to a separate file (#194398) This PR factors out the Flang/Fortranly only options from Options.td into a separately file (FlangOptions.td). Assisted-by: codex --- clang/include/clang/Options/FlangOptions.td | 404 ++++++++++++++++++++ clang/include/clang/Options/Options.td | 402 +------------------ flang/docs/FlangDriver.md | 20 +- 3 files changed, 417 insertions(+), 409 deletions(-) create mode 100644 clang/include/clang/Options/FlangOptions.td diff --git a/clang/include/clang/Options/FlangOptions.td b/clang/include/clang/Options/FlangOptions.td new file mode 100644 index 000000000000..ffb64646709d --- /dev/null +++ b/clang/include/clang/Options/FlangOptions.td @@ -0,0 +1,404 @@ +//===--- FlangOptions.td - Flang-specific options ------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +def flang_ignored_w_Group : OptionGroup<"">, + Group, Flags<[Ignored]>, Visibility<[FlangOption]>; + +multiclass FlangIgnoredDiagOpt { + def unsupported_warning_w#NAME : Flag<["-", "--"], "W"#name>, + Visibility<[FlangOption]>, Group; +} + +// Generic gfortran options. +def A_DASH : Joined<["-"], "A-">, Group; +def static_libgfortran : Flag<["-"], "static-libgfortran">, Group; + +// "f" options with values for gfortran. +def fblas_matmul_limit_EQ : Joined<["-"], "fblas-matmul-limit=">, Group; +def fcheck_EQ : Joined<["-"], "fcheck=">, Group; +def ffpe_trap_EQ : Joined<["-"], "ffpe-trap=">, Group; +def ffree_line_length_VALUE : Joined<["-"], "ffree-line-length-">, Group; +def finit_character_EQ : Joined<["-"], "finit-character=">, Group; +def finit_integer_EQ : Joined<["-"], "finit-integer=">, Group; +def finit_logical_EQ : Joined<["-"], "finit-logical=">, Group; +def finit_real_EQ : Joined<["-"], "finit-real=">, Group; +def fmax_array_constructor_EQ : Joined<["-"], "fmax-array-constructor=">, Group; +def fmax_errors_EQ : Joined<["-"], "fmax-errors=">, Group; +def fmax_stack_var_size_EQ : Joined<["-"], "fmax-stack-var-size=">, Group; +def fmax_subrecord_length_EQ : Joined<["-"], "fmax-subrecord-length=">, Group; +def frecord_marker_EQ : Joined<["-"], "frecord-marker=">, Group; + +// "f" flags for gfortran. +defm aggressive_function_elimination : BooleanFFlag<"aggressive-function-elimination">, Group; +defm align_commons : BooleanFFlag<"align-commons">, Group; +defm all_intrinsics : BooleanFFlag<"all-intrinsics">, Group; +def fautomatic : Flag<["-"], "fautomatic">; // -fno-automatic is significant +defm backtrace : BooleanFFlag<"backtrace">, Group; +defm bounds_check : BooleanFFlag<"bounds-check">, Group; +defm check_array_temporaries : BooleanFFlag<"check-array-temporaries">, Group; +defm cray_pointer : BooleanFFlag<"cray-pointer">, Group; +defm d_lines_as_code : BooleanFFlag<"d-lines-as-code">, + HelpText<"Treat fixed form lines with 'd' or 'D' in the " + "first column as blank.">, + Group, + Visibility<[FlangOption, FC1Option]>; +defm d_lines_as_comments : BooleanFFlag<"d-lines-as-comments">, + HelpText<"Treat fixed form lines with 'd' or 'D' in " + "the first column as comments.">, + Group, + Visibility<[FlangOption, FC1Option]>; +defm dollar_ok : BooleanFFlag<"dollar-ok">, Group; +defm dump_fortran_optimized : BooleanFFlag<"dump-fortran-optimized">, Group; +defm dump_fortran_original : BooleanFFlag<"dump-fortran-original">, Group; +defm dump_parse_tree : BooleanFFlag<"dump-parse-tree">, Group; +defm external_blas : BooleanFFlag<"external-blas">, Group; +defm f2c : BooleanFFlag<"f2c">, Group; +defm frontend_optimize : BooleanFFlag<"frontend-optimize">, Group; +defm init_local_zero : BooleanFFlag<"init-local-zero">, Group; +defm integer_4_integer_8 : BooleanFFlag<"integer-4-integer-8">, Group; +defm max_identifier_length : BooleanFFlag<"max-identifier-length">, Group; +defm module_private : BooleanFFlag<"module-private">, Group; +defm pack_derived : BooleanFFlag<"pack-derived">, Group; +//defm protect_parens : BooleanFFlag<"protect-parens">, Group; +defm range_check : BooleanFFlag<"range-check">, Group; +defm real_4_real_10 : BooleanFFlag<"real-4-real-10">, Group; +defm real_4_real_16 : BooleanFFlag<"real-4-real-16">, Group; +defm real_4_real_8 : BooleanFFlag<"real-4-real-8">, Group; +defm real_8_real_10 : BooleanFFlag<"real-8-real-10">, Group; +defm real_8_real_16 : BooleanFFlag<"real-8-real-16">, Group; +defm real_8_real_4 : BooleanFFlag<"real-8-real-4">, Group; +defm recursive : BooleanFFlag<"recursive">, Group; +defm second_underscore : BooleanFFlag<"second-underscore">, Group; +defm sign_zero : BooleanFFlag<"sign-zero">, Group; +defm whole_file : BooleanFFlag<"whole-file">, Group; + +// -W options unsupported by flang. +// If any of these options are passed to flang's driver, +// a warning will be raised and the argument will be claimed. +defm : FlangIgnoredDiagOpt<"extra">; +defm : FlangIgnoredDiagOpt<"aliasing">; +defm : FlangIgnoredDiagOpt<"ampersand">; +defm : FlangIgnoredDiagOpt<"array-bounds">; +defm : FlangIgnoredDiagOpt<"c-binding-type">; +defm : FlangIgnoredDiagOpt<"character-truncation">; +defm : FlangIgnoredDiagOpt<"conversion">; +defm : FlangIgnoredDiagOpt<"do-subscript">; +defm : FlangIgnoredDiagOpt<"function-elimination">; +defm : FlangIgnoredDiagOpt<"implicit-interface">; +defm : FlangIgnoredDiagOpt<"implicit-procedure">; +defm : FlangIgnoredDiagOpt<"intrinsic-shadow">; +defm : FlangIgnoredDiagOpt<"use-without-only">; +defm : FlangIgnoredDiagOpt<"intrinsics-std">; +defm : FlangIgnoredDiagOpt<"line-truncation">; +defm : FlangIgnoredDiagOpt<"no-align-commons">; +defm : FlangIgnoredDiagOpt<"no-overwrite-recursive">; +defm : FlangIgnoredDiagOpt<"no-tabs">; +defm : FlangIgnoredDiagOpt<"real-q-constant">; +defm : FlangIgnoredDiagOpt<"surprising">; +defm : FlangIgnoredDiagOpt<"underflow">; +defm : FlangIgnoredDiagOpt<"unused-parameter">; +defm : FlangIgnoredDiagOpt<"realloc-lhs">; +defm : FlangIgnoredDiagOpt<"realloc-lhs-all">; +defm : FlangIgnoredDiagOpt<"frontend-loop-interchange">; +defm : FlangIgnoredDiagOpt<"target-lifetime">; + +def shared_libflangrt : Flag<["-"], "shared-libflangrt">, + HelpText<"Link the flang-rt shared library">, Group, + Visibility<[FlangOption]>, Flags<[NoArgumentUnused]>; +def static_libflangrt : Flag<["-"], "static-libflangrt">, + HelpText<"Link the flang-rt static library">, Group, + Visibility<[FlangOption]>, Flags<[NoArgumentUnused]>; + +//===----------------------------------------------------------------------===// +// FlangOption + NoXarchOption +//===----------------------------------------------------------------------===// + +def flang_experimental_hlfir : Flag<["-"], "flang-experimental-hlfir">, + Flags<[HelpHidden]>, Visibility<[FlangOption, FC1Option]>, + HelpText<"Use HLFIR lowering (experimental)">; + +def flang_deprecated_no_hlfir : Flag<["-"], "flang-deprecated-no-hlfir">, + Flags<[HelpHidden]>, Visibility<[FlangOption, FC1Option]>, + HelpText<"Do not use HLFIR lowering (deprecated)">; + +//===----------------------------------------------------------------------===// +// FlangOption + CoreOption + NoXarchOption +//===----------------------------------------------------------------------===// + +def Xflang : Separate<["-"], "Xflang">, + HelpText<"Pass to the flang compiler">, MetaVarName<"">, + Flags<[NoXarchOption]>, Visibility<[FlangOption]>, + Group; + +//===----------------------------------------------------------------------===// +// FlangOption and FC1 Options +//===----------------------------------------------------------------------===// + +let Visibility = [FC1Option, FlangOption] in { + +def cpp : Flag<["-"], "cpp">, Group, + HelpText<"Enable predefined and command line preprocessor macros">; +def nocpp : Flag<["-"], "nocpp">, Group, + HelpText<"Disable predefined and command line preprocessor macros">; +def module_dir : JoinedOrSeparate<["-"], "module-dir">, MetaVarName<"">, + HelpText<"Put MODULE files in ">, + DocBrief<[{This option specifies where to put .mod files for compiled modules. +It is also added to the list of directories to be searched by an USE statement. +The default is the current directory.}]>; + +def ffixed_form : Flag<["-"], "ffixed-form">, Group, + HelpText<"Process source files in fixed form">; +def ffree_form : Flag<["-"], "ffree-form">, Group, + HelpText<"Process source files in free form">; +def ffixed_line_length_EQ : Joined<["-"], "ffixed-line-length=">, Group, + HelpText<"Use as character line width in fixed mode">, + DocBrief<[{Set column after which characters are ignored in typical fixed-form lines in the source +file}]>; +def ffixed_line_length_VALUE : Joined<["-"], "ffixed-line-length-">, Group, Alias; +def fconvert_EQ : Joined<["-"], "fconvert=">, Group, + HelpText<"Set endian conversion of data for unformatted files">; +def fdefault_double_8 : Flag<["-"],"fdefault-double-8">, Group, + HelpText<"Set the default double precision kind to an 8 byte wide type">; +def fdefault_integer_8 : Flag<["-"],"fdefault-integer-8">, Group, + HelpText<"Set the default integer and logical kind to an 8 byte wide type">; +def fdefault_real_8 : Flag<["-"],"fdefault-real-8">, Group, + HelpText<"Set the default real kind to an 8 byte wide type">; +def fdefault_integer_4 : Flag<["-"],"fdefault-integer-4">, Group, + HelpText<"Set the default integer and logical kind to a 4 byte wide type">; +def fdefault_real_4 : Flag<["-"],"fdefault-real-4">, Group, + HelpText<"Set the default real kind to a 4 byte wide type">; +def fdisable_real_3 : Flag<["-"],"fdisable-real-3">, Group, + HelpText<"Disable real(KIND=3) from TargetCharacteristics">, Flags<[HelpHidden]>; +def fdisable_real_10 : Flag<["-"],"fdisable-real-10">, Group, + HelpText<"Disable real(KIND=10) from TargetCharacteristics">, Flags<[HelpHidden]>; +def fdisable_integer_2 : Flag<["-"],"fdisable-integer-2">, Group, + HelpText<"Disable integer(KIND=2) from TargetCharacteristics">, Flags<[HelpHidden]>; +def fdisable_integer_16 : Flag<["-"],"fdisable-integer-16">, Group, + HelpText<"Disable integer(KIND=16) from TargetCharacteristics">, Flags<[HelpHidden]>; +def flarge_sizes : Flag<["-"],"flarge-sizes">, Group, + HelpText<"Use INTEGER(KIND=8) for the result type in size-related intrinsics">; + +def falternative_parameter_statement : Flag<["-"], "falternative-parameter-statement">, Group, + HelpText<"Enable the old style PARAMETER statement">; +def fintrinsic_modules_path : Separate<["-"], "fintrinsic-modules-path">, Group, MetaVarName<"">, + HelpText<"Specify where to find the compiled intrinsic modules">, + DocBrief<[{This option specifies the location of pre-compiled intrinsic modules, + if they are not in the default location expected by the compiler.}]>; +def fintrinsic_modules_path_EQ : Joined<["-"], "fintrinsic-modules-path=">, + Group, Alias; + +defm backslash : OptInFC1FFlag<"backslash", "Specify that backslash in string introduces an escape character">; +defm xor_operator : OptInFC1FFlag<"xor-operator", "Enable .XOR. as a synonym of .NEQV.">; +defm logical_abbreviations : OptInFC1FFlag<"logical-abbreviations", "Enable logical abbreviations">; +defm implicit_none : OptInFC1FFlag<"implicit-none", "No implicit typing allowed unless overridden by IMPLICIT statements">; +defm implicit_none_ext : OptInFC1FFlag<"implicit-none-ext", "No implicit externals allowed">; +defm underscoring : OptInFC1FFlag<"underscoring", "Appends one trailing underscore to external names">; +defm ppc_native_vec_elem_order: BoolOptionWithoutMarshalling<"f", "ppc-native-vector-element-order", + PosFlag, + NegFlag>; +defm unsigned : OptInFC1FFlag<"unsigned", "Enables UNSIGNED type">; + +def fno_automatic : Flag<["-"], "fno-automatic">, Group, + HelpText<"Implies the SAVE attribute for non-automatic local objects in subprograms unless RECURSIVE">; + +defm repack_arrays + : BoolOptionWithoutMarshalling< + "f", "repack-arrays", PosFlag, + NegFlag, + BothFlags<[], [], + " non-contiguous assumed shape dummy arrays into " + "contiguous memory">>, + DocBrief<[{Create temporary copies of non-contiguous assumed shape dummy +arrays in subprogram prologues, and destroy them in subprogram epilogues. +The temporary copy is initialized with values from the original array +in the prologue, if needed. In the epilogue, the current values +in the temporary array are copied into the original array, if needed. + +Accessing the contiguous temporary in the program code may result +in faster execution comparing to accessing elements of the original array, +when they are sparse in memory. At the same time, the overhead +of copying values between the original and the temporary arrays +may be significant, which may slow down some programs. + +Enabling array repacking may also change the behavior of certain +programs: + +* The copy actions may introduce a data race in valid OpenACC/OpenMP programs. + For example, if different threads execute the same subprogram + with a non-contiguous assumed shape dummy array, and the different threads + access unrelated parts of the array, then the whole array copy + made in each thread will cause a data race. +* OpenACC/OpenMP offload programs may behave incorrectly with regards + to the device data environment, due to the fact that the original + array and the temporary may have different presence status on the device. +* ``IS_CONTIGUOUS`` intrinsic may return ``TRUE`` with the array repacking + enabled, whereas if would return ``FALSE`` with the repacking disabled. +* The result of ``LOC`` intrinsic applied to an actual argument associated + with a non-contiguous assumed shape dummy array, may be different + from the result of ``LOC`` applied to the dummy array.}]>; + +def frepack_arrays_contiguity_EQ + : Joined<["-"], "frepack-arrays-contiguity=">, + Group, + Values<"whole,innermost">, + HelpText< + "When -frepack-arrays is in effect, 'whole' enables " + "repacking for arrays that are non-contiguous in any dimension, " + "'innermost' enables repacking for arrays that are non-contiguous " + "in the innermost dimension (the default)">; + +defm save_main_program : BoolOptionWithoutMarshalling<"f", "save-main-program", + PosFlag, + NegFlag>; + +defm stack_arrays : BoolOptionWithoutMarshalling<"f", "stack-arrays", + PosFlag, + NegFlag>; + +defm safe_trampoline : BoolOptionWithoutMarshalling<"f", + "safe-trampoline", + PosFlag, + NegFlag>; + +defm loop_versioning : BoolOptionWithoutMarshalling<"f", "version-loops-for-stride", + PosFlag, + NegFlag>; + +defm stack_repack_arrays + : BoolOptionWithoutMarshalling< + "f", "stack-repack-arrays", + PosFlag, + NegFlag< + SetFalse, [], [], + "Allocate -frepack-arrays temporaries on the heap (default)">>, + DocBrief<[{Controls whether the array temporaries created under +**-frepack-arrays** are allocated on the stack or on the heap. + +By default, the heap is used. Allocations of polymorphic types +are always done on the heap, though this may change in future releases. + }]>; + +defm unsafe_cray_pointers : BoolOptionWithoutMarshalling<"f", "unsafe-cray-pointers", + PosFlag, + NegFlag>; + +def fhermetic_module_files : Flag<["-"], "fhermetic-module-files">, Group, + HelpText<"Emit hermetic module files (no nested USE association)">; + +def fdo_concurrent_to_openmp_EQ : Joined<["-"], "fdo-concurrent-to-openmp=">, + HelpText<"Try to map `do concurrent` loops to OpenMP [none|host|device]">, + Values<"none, host, device">; + +def J : JoinedOrSeparate<["-"], "J">, + Flags<[RenderJoined]>, Group, Alias; + +def ffast_real_mod : Flag<["-"], "ffast-real-mod">, Group, + HelpText<"Enable optimization of MOD for REAL types">; +def fno_fast_real_mod : Flag<["-"], "fno-fast-real-mod">, Group, + HelpText<"Disable optimization of MOD for REAL types in presence of -ffast-math">; + +defm init_global_zero : BoolOptionWithoutMarshalling<"f", "init-global-zero", + PosFlag, + NegFlag>; + +def fno_realloc_lhs : Flag<["-"], "fno-realloc-lhs">, Group, + HelpText<"An allocatable left-hand side of an intrinsic assignment is assumed to be allocated and match the shape/type of the right-hand side">; +def frealloc_lhs : Flag<["-"], "frealloc-lhs">, Group, + HelpText<"If an allocatable left-hand side of an intrinsic assignment is unallocated or its shape/type does not match the right-hand side, then it is automatically (re)allocated">; + +//===----------------------------------------------------------------------===// +// Coarray Options +//===----------------------------------------------------------------------===// + +def fcoarray : Flag<["-"], "fcoarray">, + Group, + HelpText<"Enable Coarray features">; + +} // let Visibility = [FC1Option, FlangOption] + +//===----------------------------------------------------------------------===// +// FC1 Options +//===----------------------------------------------------------------------===// + +let Visibility = [FC1Option] in { + +def ffp_maxmin_behavior_EQ + : Joined<["-"], "ffp-maxmin-behavior=">, + Flags<[HelpHidden]>, + Group, + Values<"legacy,portable,extremum,extremenum">, + HelpText<"Control max/min and [max|min][loc|val] behavior: " + "legacy (cmp+select), portable (same as legacy, " + " but may use max/minNum when -fno-signed-zeros " + "-fno-honor-nans), extremum (IEEE-754-2019 maximum/minimum), " + "extremenum (IEEE-754-2008 max/minNum)">; + +def fget_definition : MultiArg<["-"], "fget-definition", 3>, + HelpText<"Get the symbol definition from ">, + Group; +def test_io : Flag<["-"], "test-io">, Group, + HelpText<"Run the InputOuputTest action. Use for development and testing only.">; +def fdebug_unparse_no_sema : Flag<["-"], "fdebug-unparse-no-sema">, Group, + HelpText<"Unparse and stop (skips the semantic checks)">, + DocBrief<[{Only run the parser, then unparse the parse-tree and output the +generated Fortran source file. Semantic checks are disabled.}]>; +def fdebug_unparse : Flag<["-"], "fdebug-unparse">, Group, + HelpText<"Unparse and stop.">, + DocBrief<[{Run the parser and the semantic checks. Then unparse the +parse-tree and output the generated Fortran source file.}]>; +def fdebug_unparse_with_symbols : Flag<["-"], "fdebug-unparse-with-symbols">, Group, + HelpText<"Unparse with symbols and stop.">; +def fdebug_unparse_with_modules : Flag<["-"], "fdebug-unparse-with-modules">, Group, + HelpText<"Unparse with dependent modules and stop.">; +def fdebug_dump_symbols : Flag<["-"], "fdebug-dump-symbols">, Group, + HelpText<"Dump symbols after the semantic analysis">; +def fdebug_dump_parse_tree : Flag<["-"], "fdebug-dump-parse-tree">, Group, + HelpText<"Dump the parse tree">, + DocBrief<[{Run the Parser and the semantic checks, and then output the +parse tree.}]>; +def fdebug_dump_pft : Flag<["-"], "fdebug-dump-pft">, Group, + HelpText<"Dump the pre-fir parse tree">; +def fdebug_dump_parse_tree_no_sema : Flag<["-"], "fdebug-dump-parse-tree-no-sema">, Group, + HelpText<"Dump the parse tree (skips the semantic checks)">, + DocBrief<[{Run the Parser and then output the parse tree. Semantic +checks are disabled.}]>; +def fdebug_dump_all : Flag<["-"], "fdebug-dump-all">, Group, + HelpText<"Dump symbols and the parse tree after the semantic checks">; +def fdebug_dump_provenance : Flag<["-"], "fdebug-dump-provenance">, Group, + HelpText<"Dump provenance">; +def fdebug_dump_parsing_log : Flag<["-"], "fdebug-dump-parsing-log">, Group, + HelpText<"Run instrumented parse and dump the parsing log">; +def fdebug_measure_parse_tree : Flag<["-"], "fdebug-measure-parse-tree">, Group, + HelpText<"Measure the parse tree">; +def fdebug_pre_fir_tree : Flag<["-"], "fdebug-pre-fir-tree">, Group, + HelpText<"Dump the pre-FIR tree">; +def fdebug_module_writer : Flag<["-"],"fdebug-module-writer">, + HelpText<"Enable debug messages while writing module files">; +def fget_symbols_sources : Flag<["-"], "fget-symbols-sources">, Group, + HelpText<"Dump symbols and their source code locations">; + +def module_suffix : Separate<["-"], "module-suffix">, Group, MetaVarName<"">, + HelpText<"Use as the suffix for module files (the default value is `.mod`)">; +def fno_reformat : Flag<["-"], "fno-reformat">, Group, + HelpText<"Dump the cooked character stream in -E mode">; +def fpreprocess_include_lines : Flag<["-"], "fpreprocess-include-lines">, Group, + HelpText<"Treat INCLUDE lines like #include directives in -E mode">; +defm analyzed_objects_for_unparse : OptOutFC1FFlag<"analyzed-objects-for-unparse", "", "Do not use the analyzed objects when unparsing">; + +def emit_fir : Flag<["-"], "emit-fir">, Group, + HelpText<"Build the parse tree, then lower it to FIR">; +def emit_mlir : Flag<["-"], "emit-mlir">, Alias; + +def emit_hlfir : Flag<["-"], "emit-hlfir">, Group, + HelpText<"Build the parse tree, then lower it to HLFIR">; + +} // let Visibility = [FC1Option] diff --git a/clang/include/clang/Options/Options.td b/clang/include/clang/Options/Options.td index c16c41ad4057..c64ebba6f3db 100644 --- a/clang/include/clang/Options/Options.td +++ b/clang/include/clang/Options/Options.td @@ -300,10 +300,6 @@ def clang_ignored_f_Group : OptionGroup<"">, def clang_ignored_m_Group : OptionGroup<"">, Group, Flags<[Ignored]>; -// Unsupported flang groups -def flang_ignored_w_Group : OptionGroup<"">, - Group, Flags<[Ignored]>, Visibility<[FlangOption]>; - // Group for clang options in the process of deprecation. // Please include the version that deprecated the flag as comment to allow // easier garbage collection. @@ -2949,12 +2945,6 @@ def fno_unsafe_math_optimizations : Flag<["-"], "fno-unsafe-math-optimizations"> Group; def fassociative_math : Flag<["-"], "fassociative-math">, Visibility<[ClangOption, FlangOption]>, Group; def fno_associative_math : Flag<["-"], "fno-associative-math">, Visibility<[ClangOption, FlangOption]>, Group; -def ffast_real_mod : Flag<["-"], "ffast-real-mod">, - Group, Visibility<[FlangOption, FC1Option]>, - HelpText<"Enable optimization of MOD for REAL types">; -def fno_fast_real_mod : Flag<["-"], "fno-fast-real-mod">, - Group, Visibility<[FlangOption, FC1Option]>, - HelpText<"Disable optimization of MOD for REAL types in presence of -ffast-math">; defm reciprocal_math : BoolFOption<"reciprocal-math", LangOpts<"AllowRecip">, DefaultFalse, PosFlag, PosFlag>; -def fno_realloc_lhs : Flag<["-"], "fno-realloc-lhs">, Group, - HelpText<"An allocatable left-hand side of an intrinsic assignment is assumed to be allocated and match the shape/type of the right-hand side">, - Visibility<[FlangOption, FC1Option]>; def fno_stack_protector : Flag<["-"], "fno-stack-protector">, Group, HelpText<"Disable the use of stack protectors">; def fno_strict_aliasing : Flag<["-"], "fno-strict-aliasing">, Group, @@ -3902,11 +3889,6 @@ def fno_strict_aliasing : Flag<["-"], "fno-strict-aliasing">, Group, def fstruct_path_tbaa : Flag<["-"], "fstruct-path-tbaa">, Group; def fno_struct_path_tbaa : Flag<["-"], "fno-struct-path-tbaa">, Group; def fno_strict_enums : Flag<["-"], "fno-strict-enums">, Group; -defm init_global_zero : BoolOptionWithoutMarshalling<"f", "init-global-zero", - PosFlag, - NegFlag>; def fno_pointer_tbaa : Flag<["-"], "fno-pointer-tbaa">, Group; def fno_temp_file : Flag<["-"], "fno-temp-file">, Group, Visibility<[ClangOption, CC1Option, CLOption, DXCOption]>, HelpText< @@ -4868,9 +4850,6 @@ defm stack_size_section : BoolFOption<"stack-size-section", PosFlag, NegFlag>; -def frealloc_lhs : Flag<["-"], "frealloc-lhs">, Group, - Visibility<[FlangOption, FC1Option]>, - HelpText<"If an allocatable left-hand side of an intrinsic assignment is unallocated or its shape/type does not match the right-hand side, then it is automatically (re)allocated">; def fstack_usage : Flag<["-"], "fstack-usage">, Group, HelpText<"Emit .su file containing information on function stack sizes">; def stack_usage_file : Separate<["-"], "stack-usage-file">, @@ -7352,11 +7331,6 @@ multiclass BooleanFFlag { def fno_#NAME : Flag<["-"], "fno-"#name>; } -multiclass FlangIgnoredDiagOpt { - def unsupported_warning_w#NAME : Flag<["-", "--"], "W"#name>, - Visibility<[FlangOption]>, Group; -} - defm : BooleanFFlag<"keep-inline-functions">, Group; def fprofile_dir : Joined<["-"], "fprofile-dir=">, Group; @@ -7467,98 +7441,7 @@ defm whole_program : BooleanFFlag<"whole-program">, Group, Group; -// Generic gfortran options. -def A_DASH : Joined<["-"], "A-">, Group; -def static_libgfortran : Flag<["-"], "static-libgfortran">, Group; - -// "f" options with values for gfortran. -def fblas_matmul_limit_EQ : Joined<["-"], "fblas-matmul-limit=">, Group; -def fcheck_EQ : Joined<["-"], "fcheck=">, Group; -def ffpe_trap_EQ : Joined<["-"], "ffpe-trap=">, Group; -def ffree_line_length_VALUE : Joined<["-"], "ffree-line-length-">, Group; -def finit_character_EQ : Joined<["-"], "finit-character=">, Group; -def finit_integer_EQ : Joined<["-"], "finit-integer=">, Group; -def finit_logical_EQ : Joined<["-"], "finit-logical=">, Group; -def finit_real_EQ : Joined<["-"], "finit-real=">, Group; -def fmax_array_constructor_EQ : Joined<["-"], "fmax-array-constructor=">, Group; -def fmax_errors_EQ : Joined<["-"], "fmax-errors=">, Group; -def fmax_stack_var_size_EQ : Joined<["-"], "fmax-stack-var-size=">, Group; -def fmax_subrecord_length_EQ : Joined<["-"], "fmax-subrecord-length=">, Group; -def frecord_marker_EQ : Joined<["-"], "frecord-marker=">, Group; - -// "f" flags for gfortran. -defm aggressive_function_elimination : BooleanFFlag<"aggressive-function-elimination">, Group; -defm align_commons : BooleanFFlag<"align-commons">, Group; -defm all_intrinsics : BooleanFFlag<"all-intrinsics">, Group; -def fautomatic : Flag<["-"], "fautomatic">; // -fno-automatic is significant -defm backtrace : BooleanFFlag<"backtrace">, Group; -defm bounds_check : BooleanFFlag<"bounds-check">, Group; -defm check_array_temporaries : BooleanFFlag<"check-array-temporaries">, Group; -defm cray_pointer : BooleanFFlag<"cray-pointer">, Group; -defm d_lines_as_code : BooleanFFlag<"d-lines-as-code">, - HelpText<"Treat fixed form lines with 'd' or 'D' in the " - "first column as blank.">, - Group, - Visibility<[FlangOption, FC1Option]>; -defm d_lines_as_comments : BooleanFFlag<"d-lines-as-comments">, - HelpText<"Treat fixed form lines with 'd' or 'D' in " - "the first column as comments.">, - Group, - Visibility<[FlangOption, FC1Option]>; -defm dollar_ok : BooleanFFlag<"dollar-ok">, Group; -defm dump_fortran_optimized : BooleanFFlag<"dump-fortran-optimized">, Group; -defm dump_fortran_original : BooleanFFlag<"dump-fortran-original">, Group; -defm dump_parse_tree : BooleanFFlag<"dump-parse-tree">, Group; -defm external_blas : BooleanFFlag<"external-blas">, Group; -defm f2c : BooleanFFlag<"f2c">, Group; -defm frontend_optimize : BooleanFFlag<"frontend-optimize">, Group; -defm init_local_zero : BooleanFFlag<"init-local-zero">, Group; -defm integer_4_integer_8 : BooleanFFlag<"integer-4-integer-8">, Group; -defm max_identifier_length : BooleanFFlag<"max-identifier-length">, Group; -defm module_private : BooleanFFlag<"module-private">, Group; -defm pack_derived : BooleanFFlag<"pack-derived">, Group; -//defm protect_parens : BooleanFFlag<"protect-parens">, Group; -defm range_check : BooleanFFlag<"range-check">, Group; -defm real_4_real_10 : BooleanFFlag<"real-4-real-10">, Group; -defm real_4_real_16 : BooleanFFlag<"real-4-real-16">, Group; -defm real_4_real_8 : BooleanFFlag<"real-4-real-8">, Group; -defm real_8_real_10 : BooleanFFlag<"real-8-real-10">, Group; -defm real_8_real_16 : BooleanFFlag<"real-8-real-16">, Group; -defm real_8_real_4 : BooleanFFlag<"real-8-real-4">, Group; -defm recursive : BooleanFFlag<"recursive">, Group; -defm second_underscore : BooleanFFlag<"second-underscore">, Group; -defm sign_zero : BooleanFFlag<"sign-zero">, Group; -defm whole_file : BooleanFFlag<"whole-file">, Group; - -// -W options unsupported by the flang compiler -// If any of these options are passed into flang's compiler driver, -// a warning will be raised and the argument will be claimed -defm : FlangIgnoredDiagOpt<"extra">; -defm : FlangIgnoredDiagOpt<"aliasing">; -defm : FlangIgnoredDiagOpt<"ampersand">; -defm : FlangIgnoredDiagOpt<"array-bounds">; -defm : FlangIgnoredDiagOpt<"c-binding-type">; -defm : FlangIgnoredDiagOpt<"character-truncation">; -defm : FlangIgnoredDiagOpt<"conversion">; -defm : FlangIgnoredDiagOpt<"do-subscript">; -defm : FlangIgnoredDiagOpt<"function-elimination">; -defm : FlangIgnoredDiagOpt<"implicit-interface">; -defm : FlangIgnoredDiagOpt<"implicit-procedure">; -defm : FlangIgnoredDiagOpt<"intrinsic-shadow">; -defm : FlangIgnoredDiagOpt<"use-without-only">; -defm : FlangIgnoredDiagOpt<"intrinsics-std">; -defm : FlangIgnoredDiagOpt<"line-truncation">; -defm : FlangIgnoredDiagOpt<"no-align-commons">; -defm : FlangIgnoredDiagOpt<"no-overwrite-recursive">; -defm : FlangIgnoredDiagOpt<"no-tabs">; -defm : FlangIgnoredDiagOpt<"real-q-constant">; -defm : FlangIgnoredDiagOpt<"surprising">; -defm : FlangIgnoredDiagOpt<"underflow">; -defm : FlangIgnoredDiagOpt<"unused-parameter">; -defm : FlangIgnoredDiagOpt<"realloc-lhs">; -defm : FlangIgnoredDiagOpt<"realloc-lhs-all">; -defm : FlangIgnoredDiagOpt<"frontend-loop-interchange">; -defm : FlangIgnoredDiagOpt<"target-lifetime">; +include "FlangOptions.td" // C++ SYCL options let Group = sycl_Group in { @@ -7581,280 +7464,6 @@ let Flags = [TargetSpecific] in { defm android_pad_segment : BooleanFFlag<"android-pad-segment">, Group; } // let Flags = [TargetSpecific] -def shared_libflangrt : Flag<["-"], "shared-libflangrt">, - HelpText<"Link the flang-rt shared library">, Group, - Visibility<[FlangOption]>, Flags<[NoArgumentUnused]>; -def static_libflangrt : Flag<["-"], "static-libflangrt">, - HelpText<"Link the flang-rt static library">, Group, - Visibility<[FlangOption]>, Flags<[NoArgumentUnused]>; - -//===----------------------------------------------------------------------===// -// FLangOption + NoXarchOption -//===----------------------------------------------------------------------===// - -def flang_experimental_hlfir : Flag<["-"], "flang-experimental-hlfir">, - Flags<[HelpHidden]>, Visibility<[FlangOption, FC1Option]>, - HelpText<"Use HLFIR lowering (experimental)">; - -def flang_deprecated_no_hlfir : Flag<["-"], "flang-deprecated-no-hlfir">, - Flags<[HelpHidden]>, Visibility<[FlangOption, FC1Option]>, - HelpText<"Do not use HLFIR lowering (deprecated)">; - -//===----------------------------------------------------------------------===// -// FLangOption + CoreOption + NoXarchOption -//===----------------------------------------------------------------------===// - -def Xflang : Separate<["-"], "Xflang">, - HelpText<"Pass to the flang compiler">, MetaVarName<"">, - Flags<[NoXarchOption]>, Visibility<[FlangOption, CLOption]>, - Group; - -//===----------------------------------------------------------------------===// -// FlangOption and FC1 Options -//===----------------------------------------------------------------------===// - -let Visibility = [FC1Option, FlangOption] in { - -def cpp : Flag<["-"], "cpp">, Group, - HelpText<"Enable predefined and command line preprocessor macros">; -def nocpp : Flag<["-"], "nocpp">, Group, - HelpText<"Disable predefined and command line preprocessor macros">; -def module_dir : JoinedOrSeparate<["-"], "module-dir">, MetaVarName<"">, - HelpText<"Put MODULE files in ">, - DocBrief<[{This option specifies where to put .mod files for compiled modules. -It is also added to the list of directories to be searched by an USE statement. -The default is the current directory.}]>; - -def ffixed_form : Flag<["-"], "ffixed-form">, Group, - HelpText<"Process source files in fixed form">; -def ffree_form : Flag<["-"], "ffree-form">, Group, - HelpText<"Process source files in free form">; -def ffixed_line_length_EQ : Joined<["-"], "ffixed-line-length=">, Group, - HelpText<"Use as character line width in fixed mode">, - DocBrief<[{Set column after which characters are ignored in typical fixed-form lines in the source -file}]>; -def ffixed_line_length_VALUE : Joined<["-"], "ffixed-line-length-">, Group, Alias; -def fconvert_EQ : Joined<["-"], "fconvert=">, Group, - HelpText<"Set endian conversion of data for unformatted files">; -def fdefault_double_8 : Flag<["-"],"fdefault-double-8">, Group, - HelpText<"Set the default double precision kind to an 8 byte wide type">; -def fdefault_integer_8 : Flag<["-"],"fdefault-integer-8">, Group, - HelpText<"Set the default integer and logical kind to an 8 byte wide type">; -def fdefault_real_8 : Flag<["-"],"fdefault-real-8">, Group, - HelpText<"Set the default real kind to an 8 byte wide type">; -def fdefault_integer_4 : Flag<["-"],"fdefault-integer-4">, Group, - HelpText<"Set the default integer and logical kind to a 4 byte wide type">; -def fdefault_real_4 : Flag<["-"],"fdefault-real-4">, Group, - HelpText<"Set the default real kind to a 4 byte wide type">; -def fdisable_real_3 : Flag<["-"],"fdisable-real-3">, Group, - HelpText<"Disable real(KIND=3) from TargetCharacteristics">, Flags<[HelpHidden]>; -def fdisable_real_10 : Flag<["-"],"fdisable-real-10">, Group, - HelpText<"Disable real(KIND=10) from TargetCharacteristics">, Flags<[HelpHidden]>; -def fdisable_integer_2 : Flag<["-"],"fdisable-integer-2">, Group, - HelpText<"Disable integer(KIND=2) from TargetCharacteristics">, Flags<[HelpHidden]>; -def fdisable_integer_16 : Flag<["-"],"fdisable-integer-16">, Group, - HelpText<"Disable integer(KIND=16) from TargetCharacteristics">, Flags<[HelpHidden]>; -def flarge_sizes : Flag<["-"],"flarge-sizes">, Group, - HelpText<"Use INTEGER(KIND=8) for the result type in size-related intrinsics">; - -def falternative_parameter_statement : Flag<["-"], "falternative-parameter-statement">, Group, - HelpText<"Enable the old style PARAMETER statement">; -def fintrinsic_modules_path : Separate<["-"], "fintrinsic-modules-path">, Group, MetaVarName<"">, - HelpText<"Specify where to find the compiled intrinsic modules">, - DocBrief<[{This option specifies the location of pre-compiled intrinsic modules, - if they are not in the default location expected by the compiler.}]>; -def fintrinsic_modules_path_EQ : Joined<["-"], "fintrinsic-modules-path=">, - Group, Alias; - -defm backslash : OptInFC1FFlag<"backslash", "Specify that backslash in string introduces an escape character">; -defm xor_operator : OptInFC1FFlag<"xor-operator", "Enable .XOR. as a synonym of .NEQV.">; -defm logical_abbreviations : OptInFC1FFlag<"logical-abbreviations", "Enable logical abbreviations">; -defm implicit_none : OptInFC1FFlag<"implicit-none", "No implicit typing allowed unless overridden by IMPLICIT statements">; -defm implicit_none_ext : OptInFC1FFlag<"implicit-none-ext", "No implicit externals allowed">; -defm underscoring : OptInFC1FFlag<"underscoring", "Appends one trailing underscore to external names">; -defm ppc_native_vec_elem_order: BoolOptionWithoutMarshalling<"f", "ppc-native-vector-element-order", - PosFlag, - NegFlag>; -defm unsigned : OptInFC1FFlag<"unsigned", "Enables UNSIGNED type">; - -def fno_automatic : Flag<["-"], "fno-automatic">, Group, - HelpText<"Implies the SAVE attribute for non-automatic local objects in subprograms unless RECURSIVE">; - -defm repack_arrays - : BoolOptionWithoutMarshalling< - "f", "repack-arrays", PosFlag, - NegFlag, - BothFlags<[], [], - " non-contiguous assumed shape dummy arrays into " - "contiguous memory">>, - DocBrief<[{Create temporary copies of non-contiguous assumed shape dummy -arrays in subprogram prologues, and destroy them in subprogram epilogues. -The temporary copy is initialized with values from the original array -in the prologue, if needed. In the epilogue, the current values -in the temporary array are copied into the original array, if needed. - -Accessing the contiguous temporary in the program code may result -in faster execution comparing to accessing elements of the original array, -when they are sparse in memory. At the same time, the overhead -of copying values between the original and the temporary arrays -may be significant, which may slow down some programs. - -Enabling array repacking may also change the behavior of certain -programs: - -* The copy actions may introduce a data race in valid OpenACC/OpenMP programs. - For example, if different threads execute the same subprogram - with a non-contiguous assumed shape dummy array, and the different threads - access unrelated parts of the array, then the whole array copy - made in each thread will cause a data race. -* OpenACC/OpenMP offload programs may behave incorrectly with regards - to the device data environment, due to the fact that the original - array and the temporary may have different presence status on the device. -* ``IS_CONTIGUOUS`` intrinsic may return ``TRUE`` with the array repacking - enabled, whereas if would return ``FALSE`` with the repacking disabled. -* The result of ``LOC`` intrinsic applied to an actual argument associated - with a non-contiguous assumed shape dummy array, may be different - from the result of ``LOC`` applied to the dummy array.}]>; - -def frepack_arrays_contiguity_EQ - : Joined<["-"], "frepack-arrays-contiguity=">, - Group, - Values<"whole,innermost">, - HelpText< - "When -frepack-arrays is in effect, 'whole' enables " - "repacking for arrays that are non-contiguous in any dimension, " - "'innermost' enables repacking for arrays that are non-contiguous " - "in the innermost dimension (the default)">; - -defm save_main_program : BoolOptionWithoutMarshalling<"f", "save-main-program", - PosFlag, - NegFlag>; - -defm stack_arrays : BoolOptionWithoutMarshalling<"f", "stack-arrays", - PosFlag, - NegFlag>; - -defm safe_trampoline : BoolOptionWithoutMarshalling<"f", - "safe-trampoline", - PosFlag, - NegFlag>; - -defm loop_versioning : BoolOptionWithoutMarshalling<"f", "version-loops-for-stride", - PosFlag, - NegFlag>; - -defm stack_repack_arrays - : BoolOptionWithoutMarshalling< - "f", "stack-repack-arrays", - PosFlag, - NegFlag< - SetFalse, [], [], - "Allocate -frepack-arrays temporaries on the heap (default)">>, - DocBrief<[{Controls whether the array temporaries created under -**-frepack-arrays** are allocated on the stack or on the heap. - -By default, the heap is used. Allocations of polymorphic types -are always done on the heap, though this may change in future releases. - }]>; - -defm unsafe_cray_pointers : BoolOptionWithoutMarshalling<"f", "unsafe-cray-pointers", - PosFlag, - NegFlag>; - -def fhermetic_module_files : Flag<["-"], "fhermetic-module-files">, Group, - HelpText<"Emit hermetic module files (no nested USE association)">; - -def fdo_concurrent_to_openmp_EQ : Joined<["-"], "fdo-concurrent-to-openmp=">, - HelpText<"Try to map `do concurrent` loops to OpenMP [none|host|device]">, - Values<"none, host, device">; -} // let Visibility = [FC1Option, FlangOption] - -def J : JoinedOrSeparate<["-"], "J">, - Flags<[RenderJoined]>, Visibility<[FlangOption, FC1Option]>, - Group, - Alias; - -//===----------------------------------------------------------------------===// -// FC1 Options -//===----------------------------------------------------------------------===// - -let Visibility = [FC1Option] in { - -def ffp_maxmin_behavior_EQ - : Joined<["-"], "ffp-maxmin-behavior=">, - Flags<[HelpHidden]>, - Group, - Values<"legacy,portable,extremum,extremenum">, - HelpText<"Control max/min and [max|min][loc|val] behavior: " - "legacy (cmp+select), portable (same as legacy, " - " but may use max/minNum when -fno-signed-zeros " - "-fno-honor-nans), extremum (IEEE-754-2019 maximum/minimum), " - "extremenum (IEEE-754-2008 max/minNum)">; - -def fget_definition : MultiArg<["-"], "fget-definition", 3>, - HelpText<"Get the symbol definition from ">, - Group; -def test_io : Flag<["-"], "test-io">, Group, - HelpText<"Run the InputOuputTest action. Use for development and testing only.">; -def fdebug_unparse_no_sema : Flag<["-"], "fdebug-unparse-no-sema">, Group, - HelpText<"Unparse and stop (skips the semantic checks)">, - DocBrief<[{Only run the parser, then unparse the parse-tree and output the -generated Fortran source file. Semantic checks are disabled.}]>; -def fdebug_unparse : Flag<["-"], "fdebug-unparse">, Group, - HelpText<"Unparse and stop.">, - DocBrief<[{Run the parser and the semantic checks. Then unparse the -parse-tree and output the generated Fortran source file.}]>; -def fdebug_unparse_with_symbols : Flag<["-"], "fdebug-unparse-with-symbols">, Group, - HelpText<"Unparse with symbols and stop.">; -def fdebug_unparse_with_modules : Flag<["-"], "fdebug-unparse-with-modules">, Group, - HelpText<"Unparse with dependent modules and stop.">; -def fdebug_dump_symbols : Flag<["-"], "fdebug-dump-symbols">, Group, - HelpText<"Dump symbols after the semantic analysis">; -def fdebug_dump_parse_tree : Flag<["-"], "fdebug-dump-parse-tree">, Group, - HelpText<"Dump the parse tree">, - DocBrief<[{Run the Parser and the semantic checks, and then output the -parse tree.}]>; -def fdebug_dump_pft : Flag<["-"], "fdebug-dump-pft">, Group, - HelpText<"Dump the pre-fir parse tree">; -def fdebug_dump_parse_tree_no_sema : Flag<["-"], "fdebug-dump-parse-tree-no-sema">, Group, - HelpText<"Dump the parse tree (skips the semantic checks)">, - DocBrief<[{Run the Parser and then output the parse tree. Semantic -checks are disabled.}]>; -def fdebug_dump_all : Flag<["-"], "fdebug-dump-all">, Group, - HelpText<"Dump symbols and the parse tree after the semantic checks">; -def fdebug_dump_provenance : Flag<["-"], "fdebug-dump-provenance">, Group, - HelpText<"Dump provenance">; -def fdebug_dump_parsing_log : Flag<["-"], "fdebug-dump-parsing-log">, Group, - HelpText<"Run instrumented parse and dump the parsing log">; -def fdebug_measure_parse_tree : Flag<["-"], "fdebug-measure-parse-tree">, Group, - HelpText<"Measure the parse tree">; -def fdebug_pre_fir_tree : Flag<["-"], "fdebug-pre-fir-tree">, Group, - HelpText<"Dump the pre-FIR tree">; -def fdebug_module_writer : Flag<["-"],"fdebug-module-writer">, - HelpText<"Enable debug messages while writing module files">; -def fget_symbols_sources : Flag<["-"], "fget-symbols-sources">, Group, - HelpText<"Dump symbols and their source code locations">; - -def module_suffix : Separate<["-"], "module-suffix">, Group, MetaVarName<"">, - HelpText<"Use as the suffix for module files (the default value is `.mod`)">; -def fno_reformat : Flag<["-"], "fno-reformat">, Group, - HelpText<"Dump the cooked character stream in -E mode">; -def fpreprocess_include_lines : Flag<["-"], "fpreprocess-include-lines">, Group, - HelpText<"Treat INCLUDE lines like #include directives in -E mode">; -defm analyzed_objects_for_unparse : OptOutFC1FFlag<"analyzed-objects-for-unparse", "", "Do not use the analyzed objects when unparsing">; - -def emit_fir : Flag<["-"], "emit-fir">, Group, - HelpText<"Build the parse tree, then lower it to FIR">; -def emit_mlir : Flag<["-"], "emit-mlir">, Alias; - -def emit_hlfir : Flag<["-"], "emit-hlfir">, Group, - HelpText<"Build the parse tree, then lower it to HLFIR">; - -} // let Visibility = [FC1Option] //===----------------------------------------------------------------------===// // Target Options (cc1 + cc1as) @@ -9271,15 +8880,6 @@ def fopenmp_host_ir_file_path : Separate<["-"], "fopenmp-host-ir-file-path">, } // let Visibility = [CC1Option, FC1Option] -//===----------------------------------------------------------------------===// -// Coarray Options -//===----------------------------------------------------------------------===// - -def fcoarray : Flag<["-"], "fcoarray">, - Group, - Visibility<[FlangOption, FC1Option]>, - HelpText<"Enable Coarray features">; - //===----------------------------------------------------------------------===// // SYCL Options //===----------------------------------------------------------------------===// diff --git a/flang/docs/FlangDriver.md b/flang/docs/FlangDriver.md index 63f2ce3e6757..2d1140510afc 100644 --- a/flang/docs/FlangDriver.md +++ b/flang/docs/FlangDriver.md @@ -76,7 +76,8 @@ will ignore it when used without `Xflang`. As hinted above, `flang` and `flang -fc1` are two separate tools. The fact that these tools are accessed through one binary, `flang`, is just an implementation detail. Each tool has a separate list of options, albeit defined -in the same file: `clang/include/clang/Options/Options.td`. +in the same files: `clang/include/clang/Options/Options.td` and +`clang/include/clang/Options/FlangOptions.td`. The separation helps us split various tasks and allows us to implement more specialised tools. In particular, `flang` is not aware of various @@ -111,9 +112,9 @@ in terms of Clang's driver library, `clangDriver`. This approach allows us to: * leverage Clang's ability to drive various backends available in LLVM, as well as linkers and assemblers. One implication of this dependency on Clang is that all of Flang's compiler -options are defined alongside Clang's options in -`clang/include/clang/Options/Options.td`. For options that are common for both -Flang and Clang, the corresponding definitions are shared. +options are defined inside the Clang subproject. Flang-only options are in +`clang/include/clang/Options/FlangOptions.td`. Options that are common to both +Flang and Clang are defined in `clang/include/clang/Options/Options.td`. Internally, a `clangDriver` based compiler driver works by creating actions that correspond to various compilation phases, e.g. `PreprocessJobClass`, @@ -242,12 +243,15 @@ Adding a new compiler option in Flang consists of two steps: ### Option Definition All of Flang's compiler and frontend driver options are defined in -`clang/include/clang/Options/Options.td` in Clang. When adding a new option to -Flang, you will either: +`clang/include/clang/Options/FlangOptions.td` and `clang/include/clang/Options/Options.td`. +When adding a new option to Flang, you will do one of the following: * extend the existing definition for an option that is already available - in one of Clang's drivers (e.g. `clang`), but not yet available in Flang, or + in one of Clang's drivers (e.g. `clang`), but not yet available in Flang. These + options will be in `clang/Options/Options.td`. * add a completely new definition if the option that you are adding has not - been defined yet. + been defined yet. These must be added to `clang/Options/FlangOptions.td` unless + they are intended to be shared with Clang, in which case they should be added + to `clang/Options/Options.td`. There are many predefined TableGen classes and records that you can use to fine tune your new option. The list of available configurations can be overwhelming