diff options
author | Fangrui Song <i@maskray.me> | 2024-03-01 16:40:26 -0800 |
---|---|---|
committer | Fangrui Song <i@maskray.me> | 2024-03-01 16:40:26 -0800 |
commit | ed0aa344a8aaab4d8eedbe800750b8dcd36b0bcd (patch) | |
tree | 2063a86986d2615ddcbd8b79a95d5f87340c0de1 | |
parent | 8bcb1cededa410016f9a00bebbce09b54e5c9f88 (diff) | |
download | llvm-ed0aa344a8aaab4d8eedbe800750b8dcd36b0bcd.zip llvm-ed0aa344a8aaab4d8eedbe800750b8dcd36b0bcd.tar.gz llvm-ed0aa344a8aaab4d8eedbe800750b8dcd36b0bcd.tar.bz2 |
[Driver] Add BoolMOption to simplify boolean -m* options
Similar to BoolFOption/BoolGOption for -f* and -g*
-rw-r--r-- | clang/include/clang/Driver/Options.td | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index 3a028fa..bef3873 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -550,6 +550,13 @@ multiclass BoolGOption<string flag_base, KeyPathAndMacro kpm, Group<g_Group>; } +multiclass BoolMOption<string flag_base, KeyPathAndMacro kpm, + Default default, FlagDef flag1, FlagDef flag2, + BothFlags both = BothFlags<[]>> { + defm NAME : BoolOption<"m", flag_base, kpm, default, flag1, flag2, both>, + Group<m_Group>; +} + // Works like BoolOption except without marshalling multiclass BoolOptionWithoutMarshalling<string prefix = "", string spelling_base, FlagDef flag1_base, FlagDef flag2_base, @@ -4600,11 +4607,10 @@ def mretpoline : Flag<["-"], "mretpoline">, Group<m_Group>, Visibility<[ClangOption, CLOption]>; def mno_retpoline : Flag<["-"], "mno-retpoline">, Group<m_Group>, Visibility<[ClangOption, CLOption]>; -defm speculative_load_hardening : BoolOption<"m", "speculative-load-hardening", +defm speculative_load_hardening : BoolMOption<"speculative-load-hardening", CodeGenOpts<"SpeculativeLoadHardening">, DefaultFalse, PosFlag<SetTrue, [], [ClangOption, CC1Option]>, - NegFlag<SetFalse>, BothFlags<[], [ClangOption, CLOption]>>, - Group<m_Group>; + NegFlag<SetFalse>, BothFlags<[], [ClangOption, CLOption]>>; def mlvi_hardening : Flag<["-"], "mlvi-hardening">, Group<m_Group>, Visibility<[ClangOption, CLOption]>, HelpText<"Enable all mitigations for Load Value Injection (LVI)">; @@ -4821,13 +4827,13 @@ def mexec_model_EQ : Joined<["-"], "mexec-model=">, Group<m_wasm_Features_Driver "explicitly terminated.">; } // let Flags = [TargetSpecific] -defm amdgpu_ieee : BoolOption<"m", "amdgpu-ieee", +defm amdgpu_ieee : BoolMOption<"amdgpu-ieee", CodeGenOpts<"EmitIEEENaNCompliantInsts">, DefaultTrue, PosFlag<SetTrue, [], [ClangOption], "Sets the IEEE bit in the expected default floating point " " mode register. Floating point opcodes that support exception flag " "gathering quiet and propagate signaling NaN inputs per IEEE 754-2008. " "This option changes the ABI. (AMDGPU only)">, - NegFlag<SetFalse, [], [ClangOption, CC1Option]>>, Group<m_Group>; + NegFlag<SetFalse, [], [ClangOption, CC1Option]>>; def mcode_object_version_EQ : Joined<["-"], "mcode-object-version=">, Group<m_Group>, HelpText<"Specify code object ABI version. Defaults to 5. (AMDGPU only)">, @@ -4846,14 +4852,14 @@ defm wavefrontsize64 : SimpleMFlag<"wavefrontsize64", "Specify wavefront size 64", "Specify wavefront size 32", " mode (AMDGPU only)">; -defm unsafe_fp_atomics : BoolOption<"m", "unsafe-fp-atomics", +defm unsafe_fp_atomics : BoolMOption<"unsafe-fp-atomics", TargetOpts<"AllowAMDGPUUnsafeFPAtomics">, DefaultFalse, PosFlag<SetTrue, [], [ClangOption, CC1Option], "Enable generation of unsafe floating point " "atomic instructions. May generate more efficient code, but may not " "respect rounding and denormal modes, and may give incorrect results " "for certain memory destinations. (AMDGPU only)">, - NegFlag<SetFalse>>, Group<m_Group>; + NegFlag<SetFalse>>; def faltivec : Flag<["-"], "faltivec">, Group<f_Group>; def fno_altivec : Flag<["-"], "fno-altivec">, Group<f_Group>; @@ -4941,11 +4947,10 @@ def mrop_protect : Flag<["-"], "mrop-protect">, def mprivileged : Flag<["-"], "mprivileged">, Group<m_ppc_Features_Group>; -defm regnames : BoolOption<"m", "regnames", +defm regnames : BoolMOption<"regnames", CodeGenOpts<"PPCUseFullRegisterNames">, DefaultFalse, PosFlag<SetTrue, [], [ClangOption, CC1Option], "Use full register names when writing assembly output">, - NegFlag<SetFalse, [], [ClangOption], "Use only register numbers when writing assembly output">>, - Group<m_Group>; + NegFlag<SetFalse, [], [ClangOption], "Use only register numbers when writing assembly output">>; } // let Flags = [TargetSpecific] def maix_small_local_exec_tls : Flag<["-"], "maix-small-local-exec-tls">, Group<m_ppc_Features_Group>, @@ -4987,10 +4992,10 @@ def mxcoff_build_id_EQ : Joined<["-"], "mxcoff-build-id=">, Group<Link_Group>, M def mignore_xcoff_visibility : Flag<["-"], "mignore-xcoff-visibility">, Group<m_Group>, HelpText<"Not emit the visibility attribute for asm in AIX OS or give all symbols 'unspecified' visibility in XCOFF object file">, Flags<[TargetSpecific]>, Visibility<[ClangOption, CC1Option]>; -defm backchain : BoolOption<"m", "backchain", +defm backchain : BoolMOption<"backchain", CodeGenOpts<"Backchain">, DefaultFalse, PosFlag<SetTrue, [], [ClangOption], "Link stack frames through backchain on System Z">, - NegFlag<SetFalse>, BothFlags<[], [ClangOption, CC1Option]>>, Group<m_Group>; + NegFlag<SetFalse>, BothFlags<[], [ClangOption, CC1Option]>>; def mno_warn_nonportable_cfstrings : Flag<["-"], "mno-warn-nonportable-cfstrings">, Group<m_Group>; def mno_omit_leaf_frame_pointer : Flag<["-"], "mno-omit-leaf-frame-pointer">, Group<m_Group>; @@ -6952,7 +6957,7 @@ def msmall_data_limit : Separate<["-"], "msmall-data-limit">, def funwind_tables_EQ : Joined<["-"], "funwind-tables=">, HelpText<"Generate unwinding tables for all functions">, MarshallingInfoInt<CodeGenOpts<"UnwindTables">>; -defm constructor_aliases : BoolOption<"m", "constructor-aliases", +defm constructor_aliases : BoolMOption<"constructor-aliases", CodeGenOpts<"CXXCtorDtorAliases">, DefaultFalse, PosFlag<SetTrue, [], [ClangOption], "Enable">, NegFlag<SetFalse, [], [ClangOption], "Disable">, |