Loading…
CppCon 2018 has ended
Back To Schedule
Wednesday, September 26 • 16:45 - 17:45
Using Compile-time Code Generation to build an LLVM IR Pattern Matcher

Sign up or log in to save this to your schedule, view media, leave feedback and see who's attending!

Although expression templates have been around for many years and are a great example of compile-time code generation, they have typically been limited to relatively short expressions who's grammar can be expressed as a tree. What do you do when you want to express something more like an assembly-language program, with loops (cycles) in it? This was the problem that I encountered when trying to identify certain loop patterns in an LLVM compiler back end. The LLVM infrastructure provides a pattern matching library, but it has some limitations -- most notably the inability to express cycles in the code it matches.

Taking the idea of expression templates and kicking it up a notch, I created a library that allows an input pattern to be expressed directly in C++ using a syntax that resembles assembly language then generate, at compile time, an actual pattern-matching subroutine customized for that pattern. In the process, I deepened my knowledge of constexpr expressions, and built an interesting infrastructure that I will now share with you.

This talk is for the advanced C++ programmer. An understanding of templates, type traits, and basic metaprogramming is assumed. No prior knowledge of LLVM or compilers is required, though compiler back-end implementers will find this talk especially interesting.

Speakers
avatar for Pablo Halpern

Pablo Halpern

Software Engineer, Halpern-Wight, Inc.
Pablo Halpern has been programming in C++ since 1989 and has been a member of the C++ Standards Committee since 2007. His major contributions to the standard have been in the areas of parallel and vector programming constructs as well as on improvements to the usability of memory... Read More →


Wednesday September 26, 2018 16:45 - 17:45 PDT
Winter Park (406)