Using an AST as a higher level interface to LLVM: getting started
For an experimental project at work, I want to try my hand at code
generation. For the moment, I want my program to generate ASTs, not get
them by parsing C files. Then I'd like to translate them into code and
call into them. This is all on amd64. For now Linux, if it proves
successful, Windows as well.
How should I get started? A couple questions:
- How easy is it to create an AST? Can I just new the nodes I need and
point them at each other? Is there any non-obvious setup I need to do
- If I want to see the AST that corresponds to a given C construct, is
here a way to hack clang to print out the AST? Where would I put that
- Once I have my AST, how do I compile it, load it & run it?