[cfe-dev] Patch: AST Matcher Framwork and an example tool

David Chisnall csdavec at swan.ac.uk
Fri Jun 17 11:28:45 PDT 2011


On 17 Jun 2011, at 18:22, Chris Lattner wrote:

> How about we start with *just* the AST pattern matching APIs, iterating on them until we get to something that can go in, with some warnings switched over to using it as an example.  As a step towards this, please take a look at include/llvm/Support/PatternMatch.h, which does pattern matching on LLVM IR.  I'd prefer the clang matching API to look more similar to it.

It might also be worth looking at some of the papers from the Viewpoint Research Institute.  They wrote an entire optimising compiler in OMeta (a pattern-matching DSL).  ASTs are constructed by pattern matching on a character stream.  ASTs are optimised by pattern matching on ASTs.  Assembly is generated by pattern matching on ASTs.  Optimised machine code is optimised again by patching on assembly.  The entire compiler is under 500 lines of code, and is self-hosting (although, obviously, only implements a few optimisations).

David

-- Send from my Jacquard Loom



More information about the cfe-dev mailing list