Would you mind uploading the clang-side of this patch to phabricator? It will make it a little easier for me to perform a review. See http://llvm.org/docs/Phabricator.html for more details.
On Mon, Nov 30, 2015 at 9:13 AM, Louis Dionne via cfe-commits < cfe-commits@lists.llvm.org> wrote: > Hi, > > I wrote a patch that adds a `__nth_element` builtin that allows fetching > the > n-th type of a parameter pack with very little compile-time overhead. The > patch > was inspired by r252036 and r252115 by David Majnemer, which add a similar > `__make_integer_seq` builtin for efficiently creating a > `std::integer_sequence`. > At its core, the builtin makes the following specialization > > __nth_element<i, T1, ..., Tn> > > equivalent to Ti. Further analysis of the problem this patch is trying to > solve > is available on a blog post I just wrote [1]. The post also present > benchmarks > showing the compile-time improvement over existing techniques. > > The patch is currently in a very rough state. It is my first time > contributing > to Clang, and I encountered some issues that I hacked around just to get a > working solution. If there is interest in this patch, I will gladly improve > it until it is in an acceptable state, but I will most likely need some > pointers to do so. Things that are hacky right now: > > 1. I wasn't able to create a non-type template parameter from a builtin > type. > Hence, `__nth_element` must currently be used as > __nth_element<TypeOfTheIndex, Index, Ts...> > instead of just `__nth_element<Index, Ts...>`, while forcing `Index` to > be > something like `unsigned long`. This way, I was able to copy Majnemer's > code that creates non-type template parameters. This is probably trivial > to change, but I couldn't figure it out immediately. > > 2. I wasn't sure how to retrieve an actual integer from an `APSInt`, so > right > now I use `getExtValue()`. This is probably wrong, as I didn't really > understand what I was doing. > > There are certainly other issues that a code review would address, if we > make > it that far. Also, the name `__nth_element` is badly chosen, since it seems > to refer to the `nth_element` algorithm of the standard library. We should > settle on something else, but I have no preference. > > I also wrote a corresponding patch for libc++ to use the builtin to > implement > `std::tuple_element`. You can find both patches attached to this message. > Also, > these patches were initially posted as bug reports [2] and [3], > respectively. > > Please let me know if there is any interest for going forward with these > patches. > > Regards, > Louis Dionne > > [1]: http://ldionne.com/2015/11/29/efficient-parameter-pack-indexing > [2]: https://llvm.org/bugs/show_bug.cgi?id=25670 > [3]: https://llvm.org/bugs/show_bug.cgi?id=25671 > > > _______________________________________________ > cfe-commits mailing list > cfe-commits@lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits > >
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits