From ed0aa344a8aaab4d8eedbe800750b8dcd36b0bcd Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Fri, 1 Mar 2024 16:40:26 -0800 Subject: [Driver] Add BoolMOption to simplify boolean -m* options Similar to BoolFOption/BoolGOption for -f* and -g* --- clang/include/clang/Driver/Options.td | 31 ++++++++++++++++++------------- 1 file 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; } +multiclass BoolMOption> { + defm NAME : BoolOption<"m", flag_base, kpm, default, flag1, flag2, both>, + Group; +} + // Works like BoolOption except without marshalling multiclass BoolOptionWithoutMarshalling, Group, Visibility<[ClangOption, CLOption]>; def mno_retpoline : Flag<["-"], "mno-retpoline">, 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, - NegFlag, BothFlags<[], [ClangOption, CLOption]>>, - Group; + NegFlag, BothFlags<[], [ClangOption, CLOption]>>; def mlvi_hardening : Flag<["-"], "mlvi-hardening">, 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; } // let Flags = [TargetSpecific] -defm amdgpu_ieee : BoolOption<"m", "amdgpu-ieee", +defm amdgpu_ieee : BoolMOption<"amdgpu-ieee", CodeGenOpts<"EmitIEEENaNCompliantInsts">, DefaultTrue, PosFlag, - NegFlag>, Group; + NegFlag>; def mcode_object_version_EQ : Joined<["-"], "mcode-object-version=">, 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, - NegFlag>, Group; + NegFlag>; def faltivec : Flag<["-"], "faltivec">, Group; def fno_altivec : Flag<["-"], "fno-altivec">, Group; @@ -4941,11 +4947,10 @@ def mrop_protect : Flag<["-"], "mrop-protect">, def mprivileged : Flag<["-"], "mprivileged">, Group; -defm regnames : BoolOption<"m", "regnames", +defm regnames : BoolMOption<"regnames", CodeGenOpts<"PPCUseFullRegisterNames">, DefaultFalse, PosFlag, - NegFlag>, - Group; + NegFlag>; } // let Flags = [TargetSpecific] def maix_small_local_exec_tls : Flag<["-"], "maix-small-local-exec-tls">, Group, @@ -4987,10 +4992,10 @@ def mxcoff_build_id_EQ : Joined<["-"], "mxcoff-build-id=">, Group, M def mignore_xcoff_visibility : Flag<["-"], "mignore-xcoff-visibility">, 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, - NegFlag, BothFlags<[], [ClangOption, CC1Option]>>, Group; + NegFlag, BothFlags<[], [ClangOption, CC1Option]>>; def mno_warn_nonportable_cfstrings : Flag<["-"], "mno-warn-nonportable-cfstrings">, Group; def mno_omit_leaf_frame_pointer : Flag<["-"], "mno-omit-leaf-frame-pointer">, 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>; -defm constructor_aliases : BoolOption<"m", "constructor-aliases", +defm constructor_aliases : BoolMOption<"constructor-aliases", CodeGenOpts<"CXXCtorDtorAliases">, DefaultFalse, PosFlag, NegFlag, -- cgit v1.1