[LLVMdev] [OT] Control Flow Graph(CFG) into Abstract Syntax Tree(AST)

James Courtier-Dutton james.dutton at gmail.com
Thu Sep 13 03:58:09 PDT 2012


I know most compilers go from AST to CFG.
I am writing a decompiler, so I was wondering if anyone knew of any
documents describing how best to get from CFG to AST.
The decompiler project is open source.

The decompiler already contains a disassembler and a virtual machine
resulting in an annotated CFG. It uses information gained from using a
virtual machine to annotate the CFG. Another use of the VM will be to
help analyze self modifying code.

The decompiler can output C source code form the CFG, but it is not
easy to understand the result due to lack of structure such as for {}
I wish to create an AST from the CFG in order to be able to output for
{}, while {}  and if...then...else structure.
The CFG to AST step seems a little complicated, so I was looking for
some pointers to how best to do it to save me re-inventing the wheel.

Kind Regards


More information about the llvm-dev mailing list