[cfe-dev] __attribute__((enable_if(...))) for de-macroifying the builtin headers

Sanjay Patel spatel at rotateright.com
Mon Apr 20 09:30:37 PDT 2015


On Fri, Apr 17, 2015 at 2:30 PM, Sean Silva <chisophugis at gmail.com> wrote:

>
> On Thu, Apr 16, 2015 at 11:10 AM, Sanjay Patel <spatel at rotateright.com>
> wrote:
>
>> Hi Sean -
>>
>> Thanks for pushing on this.
>>
>> Re: the complicated cases - in one of the recent patch reviews in this
>> area, Andrea pointed out a major shortcoming of the header hacks: we're
>> optimizing vector intrinsics into generic IR even at -O0. This won't make
>> for happy debugging.
>>
>> So I've been optimizing these in InstCombine rather than headers recently:
>> http://reviews.llvm.org/rL235124
>> http://reviews.llvm.org/rL232852
>>
>> This is a much nicer solution IMO, and I haven't heard any objections to
>> this approach, so I'm hoping we'll clean up all of the complicated macros
>> eventually.
>>
>
> How are you handling the frontend checks for them being a compile-time
> constant? I think that at the very least the enable_if will allow removing
> the macros which I thought were just for that purpose (or are you planning
> on adding the intrinsics directly as clang intrinsics?).
>
>
Handling the intrinsics in InstCombine decouples the optimization part of
the problem from the constant checking. So if we can handle the simple
macros using enable_if, then we should be able to convert the complicated
macros back into their original simple inline function forms + enable_if
checking and do all of the optimization work in InstCombine for those cases
too.

Put another way: if enable_if works for one case, then we should be able to
make it work for all cases and eventually have a uniform header file; each
intrinsic can be a simple function call with all optimization deferred to
InstCombine.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20150420/d5239759/attachment.html>


More information about the cfe-dev mailing list