[PATCH] D97069: [clang] BoolMOption helper in Options.td

Stanislav Mekhanoshin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 19 11:04:27 PST 2021


rampitec created this revision.
rampitec added reviewers: tra, kzhuravl, t-tye.
Herald added subscribers: jansvoboda11, dang.
rampitec requested review of this revision.

This is the new helper to create a boolean -m and -mno-
options.


https://reviews.llvm.org/D97069

Files:
  clang/include/clang/Driver/Options.td


Index: clang/include/clang/Driver/Options.td
===================================================================
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -425,6 +425,18 @@
               Group<g_Group>;
 }
 
+// Creates a BoolOption where both of the flags are prefixed with "m", have
+// help text specified for enabled and disabled option, and a Group optionally
+// specified by the OptGroup argument, otherwise Group<m_Group>.
+multiclass BoolMOption<string flag_base,
+                       string HelpStringEnabled, string HelpStringDisabled,
+                       OptionGroup OptGroup = m_Group> {
+  def m # NAME : Flag<["-"], "m" # flag_base >, Group<OptGroup>,
+    HelpText<HelpStringEnabled>;
+  def mno_ # NAME : Flag<["-"], "mno-" # flag_base>, Group<OptGroup>,
+    HelpText<HelpStringDisabled>;
+}
+
 // FIXME: Diagnose if target does not support protected visibility.
 class MarshallingInfoVisibility<KeyPathAndMacro kpm, code default>
   : MarshallingInfoString<kpm, default>,
@@ -3097,23 +3109,20 @@
   HelpText<"Specify code object ABI version. Defaults to 3. (AMDGPU only)">,
   MetaVarName<"<version>">, Values<"2,3,4">;
 
-def mcode_object_v3_legacy : Flag<["-"], "mcode-object-v3">, Group<m_Group>,
-  HelpText<"Legacy option to specify code object ABI V2 (-mnocode-object-v3) or V3 (-mcode-object-v3) (AMDGPU only)">;
-def mno_code_object_v3_legacy : Flag<["-"], "mno-code-object-v3">, Group<m_Group>;
-
-def mcumode : Flag<["-"], "mcumode">, Group<m_amdgpu_Features_Group>,
-  HelpText<"Specify CU (-mcumode) or WGP (-mno-cumode) wavefront execution mode (AMDGPU only)">;
-def mno_cumode : Flag<["-"], "mno-cumode">, Group<m_amdgpu_Features_Group>;
-
-def mtgsplit : Flag<["-"], "mtgsplit">, Group<m_amdgpu_Features_Group>,
-  HelpText<"Enable threadgroup split execution mode (AMDGPU only)">;
-def mno_tgsplit : Flag<["-"], "mno-tgsplit">, Group<m_amdgpu_Features_Group>,
-  HelpText<"Disable threadgroup split execution mode (AMDGPU only)">;
-
-def mwavefrontsize64 : Flag<["-"], "mwavefrontsize64">, Group<m_Group>,
-  HelpText<"Specify wavefront size 64 mode (AMDGPU only)">;
-def mno_wavefrontsize64 : Flag<["-"], "mno-wavefrontsize64">, Group<m_Group>,
-  HelpText<"Specify wavefront size 32 mode (AMDGPU only)">;
+defm code_object_v3_legacy : BoolMOption<"code-object-v3",
+  "Legacy option to specify code object ABI V3 (AMDGPU only)",
+  "Legacy option to specify code object ABI V2 (AMDGPU only)">;
+defm cumode : BoolMOption<"cumode",
+  "Specify CU wavefront execution mode (AMDGPU only)",
+  "Specify WGP wavefront execution mode (AMDGPU only)",
+  m_amdgpu_Features_Group>;
+defm tgsplit : BoolMOption<"tgsplit",
+  "Elable threadgroup split execution mode (AMDGPU only)",
+  "Disable threadgroup split execution mode (AMDGPU only)",
+  m_amdgpu_Features_Group>;
+defm wavefrontsize64 : BoolMOption<"wavefrontsize64",
+  "Specify wavefront size 64 mode (AMDGPU only)",
+  "Specify wavefront size 32 mode (AMDGPU only)">;
 
 defm unsafe_fp_atomics : BoolOption<"m", "unsafe-fp-atomics",
   TargetOpts<"AllowAMDGPUUnsafeFPAtomics">, DefaultFalse,


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D97069.325043.patch
Type: text/x-patch
Size: 3134 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210219/d33c104c/attachment-0001.bin>


More information about the llvm-commits mailing list