[PATCH] D43394: [X86] Add 'sahf' CPU feature, and emit __LAHFSAHF__ for it

Jonathan Looney via cfe-commits cfe-commits at lists.llvm.org
Sat Feb 17 10:22:52 PST 2018


On Fri, Feb 16, 2018 at 6:21 PM, Dimitry Andric <dimitry at andric.com> wrote:

> On 17 Feb 2018, at 00:12, Craig Topper via Phabricator <
> reviews at reviews.llvm.org> wrote:
> >
> > craig.topper added inline comments.
> >
> >
> > ================
> > Comment at: lib/Basic/Targets/X86.cpp:1049
> >
> > +  if (HasLAHFSAHF)
> > +    Builder.defineMacro("__LAHFSAHF__");
> > ----------------
> > dim wrote:
> >> craig.topper wrote:
> >>> Does gcc define this? It's such a low level instruction I have a hard
> time believing this define would be useful.
> >> I tried gcc 6, 7 and 8, and while they do expose stuff like
> `__POPCNT__`, I see no `__LAHFSAHF__`.  I am supposing Jonathan's original
> intent with this was to make it easily testable in source, so you can
> insert the right assembly for the target CPU.  The same could really be
> said for things like `__RDSEED__`, and some other defines...
> > Most of the defines indicate the availability of intrinsics. At least
> that was their original intent. They used to control what intrinsic header
> were included in x86intrin.h or immintrin.h. Though now we include
> everything except in MSVC compatible mode and allow the target attribute to
> provide per function control.
> >
> > I'd prefer not to add this one if gcc doesn't have it.
>
> Jonathan, can you comment on your reasons for adding the __LAHFSAHF__
> define?  Was this just a nice-to-have, or do you require it for something
> related to https://bugs.llvm.org/show_bug.cgi?id=36028 ?
>
>
Its just a "nice-to-have". Among other things, it makes it easy to
determine CPU support in case you wanted to write assembly to use this
feature. It also makes it easy to test for the behavior of the front-end
with respect to this feature. But, I don't have any current use case for
it, and won't be upset if it disappears.

Jonathan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180217/f3c440fd/attachment.html>


More information about the cfe-commits mailing list