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

Ralf Karrenberg Chareos at gmx.de
Fri Sep 21 01:51:16 PDT 2012


Hi,

Simon Moll (in CC) has written a decompiler for LLVM in his Bachelor's 
Thesis here at Saarland University. The thesis is titled "Decompilation 
of LLVM IR" and can be found here:
http://www.cdl.uni-saarland.de/publications/

The library he implemented is called "Axtor" (for "AST Extractor") and 
has been used primarily to generate OpenCL code from LLVM. In this 
context, it successfully compiles OpenCL -> LLVM -> OpenCL "cycles".
Simon will be able to give you more information, also in terms of 
license details which I don't remember.

Cheers,
Ralf


On 13.09.2012 12:58, James Courtier-Dutton wrote:
> Hi,
>
> 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.
> https://github.com/jcdutton/libbeauty
>
> 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 {}
> loops.
> 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
>
> James
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>



More information about the llvm-dev mailing list