This is the new helper to create a boolean -m and -mno-
options.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
If folks are ok with this approach, we probably will need to update other targets' *m* flags (e.g. -m[no-]unimplemented_simd128, -m[no-]fix_cortex_a53_835769, etc.)
clang/include/clang/Driver/Options.td | ||
---|---|---|
436 | Can you please rename this to BoolMFlag and model it after BoolFFlag? The Bool?Option multiclasses were created for fine-grained control of cc1 flag marshalling, which your implementation doesn't do/need. https://clang.llvm.org/docs/InternalsManual.html#option-marshalling-infrastructure |
clang/include/clang/Driver/Options.td | ||
---|---|---|
436 | It does not seem that BoolFFlag exists? |
clang/include/clang/Driver/Options.td | ||
---|---|---|
436 | Ah, sorry, I meant OptInFFlag and OptOutFFlag. You probably won't need the KeyPathAndMacro and enablers parameters, as you're not targeting cc1. |
clang/include/clang/Driver/Options.td | ||
---|---|---|
436 | It end up with the same multiclass, just different name? After OptInFFlag is cleaned from marshalling, kpm, enablers and CC1 stuff it looks more or less the same as this one. Plus to get the same behavior as now we need separate help strings and optional group. |
clang/include/clang/Driver/Options.td | ||
---|---|---|
436 | My concern here is that naming this class BoolMOption will cause confusion. We already have BoolFOption and BoolGOption that are used for different purpose (automatic option marshalling in cc1). Note: I'm in the process of converting Opt{In,Out}FFlag instances that perform marshalling via the kpm and enablers parameters to BoolFOption instances. My end-goal is to have clear distinction between marshalling multiclasses (ending with Option) and simple multiclasses that don't do marshalling (ending with Flag). Since your multiclass doesn't perform marshalling, I'd strongly prefer the name to end with Flag. And since it's neither opt-in or opt-out (because it doesn't target cc1), how about naming it SimpleMFlag, PlainMFlag or something similar? I also think keeping the API similar to existing multiclasses would be nice from user perspective. How about using the existing the Opt{In,Out}FFlag signature (stripped of kpm and enablers? string name, string pos_prefix, string neg_prefix="", string help="", list<OptionFlag> flags=[] It supports separate help strings and you can append OptionGroup OptGroup = m_Group at the end to fit your use-case. I understand it will end up looking a lot like Opt{In,Out}FFlag, but the absence of CC1Option is pretty important, so I think it's fine. |
clang/include/clang/Driver/Options.td | ||
---|---|---|
436 | Would it make sense to rename OptInFFlag to OptInFlag, and take common prefix as a template arg, something like: multiclass OptInFlag<**string prefix**, string name, string pos_prefix, string neg_prefix="", string help="", list<OptionFlag> flags=[]> { Then we will have existing "optin flags" as defm cuda_short_ptr : OptInFlag<"f", "cuda-short-ptr", And new "optin flags" as defm tgsplit : OptInFlag<"m", "tgsplit", ? |
clang/include/clang/Driver/Options.td | ||
---|---|---|
436 | Extracting the prefix parameter is certainly possible, but I don't see how OptInFlag or OptOutFlag could be used for the options in this patch. Opt-in means that the driver recognizes two flags (the positive and the negative), while cc1 recognizes only the positive flag. The value in CompilerInvocation controlled by the flag defaults to false and can be set to true by the positive flag (the user can "opt-in" to some behavior). Opt-out means the opposite. If I'm not mistaken, neither of the options in this patch are recognized by cc1, so the concept of opt-in/opt-out doesn't apply here. |
Renamed macro as SimpleMFlag.
clang/include/clang/Driver/Options.td | ||
---|---|---|
436 |
I have renamed it. With the help it is not so easy to have a single string. Look at the uses, positive and negative options have sufficiently different text. I am also not sure about "list<OptionFlag> flags", it does not seem to have any use for the -m options. |
Thanks for renaming the multiclass.
LGTM with the typo fixed. Decision on the final signature is up to you.
clang/include/clang/Driver/Options.td | ||
---|---|---|
436 | The suggested signature doesn't have one help string, it has three: the pos_prefix, neg_prefix and common suffix help. I'm fine with leaving flags out as there's no need for them right now. | |
3160 | Small typo. |
Fixed typo.
Made it more like OptInFFlag with 3 help strings and parameter naming.
clang/include/clang/Driver/Options.td | ||
---|---|---|
436 | Right, I missed I can combine anything out of 3 strings. Added 3 strings like in OptInFFlag. |
Can you please rename this to BoolMFlag and model it after BoolFFlag?
The Bool?Option multiclasses were created for fine-grained control of cc1 flag marshalling, which your implementation doesn't do/need. https://clang.llvm.org/docs/InternalsManual.html#option-marshalling-infrastructure