This patch adds support for __builtin_cpu_is. I've tried to match the strings supported to the latest version of gcc.
I've only tested this on my Macbook so far so I'd appreciate if others would test it. An AMD system would be great.
Paths
| Differential D35449
[X86] Implement __builtin_cpu_is ClosedPublic Authored by craig.topper on Jul 14 2017, 10:42 PM.
Details Summary This patch adds support for __builtin_cpu_is. I've tried to match the strings supported to the latest version of gcc. I've only tested this on my Macbook so far so I'd appreciate if others would test it. An AMD system would be great.
Diff Detail
Event TimelineComment Actions I don't have much experience with this builtin - does gcc use it for anything but x86? google didn't turn up much. Comment Actions I think gcc supports builtin_cpu_supports and builtin_cpu_is for non-x86. We already have an x86 only implementation of __builtin_cpu_supports so I did the same here. Comment Actions I'm considering making validateCpuIs return a std::pair with the appropriate value and a tag that indicates invalid/vendor/type/subtype. This way we can remove the target based string decoding from CodeGen by reusing the validate function(with a better name). Sema can look for the invalid tag for its error. We could also make validateCpuSupports return the feature bit number for __builtin_cpu_supports and reuse it in CodeGen. Comment Actions Adding Erich Keane here on this since he's working on something similar for the target attribute. -eric Comment Actions From my perspective here once you and Erich get some agreement on the checking between your two bits I'm fine :) -eric Comment Actions FWIW the duplication in CGCall.cpp of the enum set is painful if you can come up with anything else it'd be awesome. I don't have any good ideas, just a fond wish :) Comment Actions @erichkeane are you ok with this code for now? I think validateCPUIs gives you what you need at least for Sema support for target attribute. You'll probably need to refactor the CG code to make your ifunc resolver. But I think you need to do that for the existing feature code that's similar anyway. And from our side conversation it sounds like you're not ready for that yet. Comment Actions
Thats correct. I think this is right based on what I currently understand, though you/I will likely need to make some additional modifications to support my features. This revision is now accepted and ready to land.Aug 10 2017, 3:23 AM Closed by commit rL310657: [X86] Implement __builtin_cpu_is (authored by ctopper). · Explain WhyAug 10 2017, 1:29 PM This revision was automatically updated to reflect the committed changes.
Revision Contents
Diff 110629 cfe/trunk/include/clang/Basic/BuiltinsX86.def
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Basic/TargetInfo.h
cfe/trunk/lib/Basic/Targets/X86.h
cfe/trunk/lib/Basic/Targets/X86.cpp
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/test/CodeGen/builtin-cpu-is.c
cfe/trunk/test/CodeGen/target-builtin-noerror.c
cfe/trunk/test/Sema/builtin-cpu-supports.c
|