[LLVMdev] Some questions about building an LLVM frontend
Chris Lattner
clattner at apple.com
Sat Aug 25 13:02:17 PDT 2007
On Aug 24, 2007, at 7:02 PM, Talin wrote:
> I've been working some more on my front-end, incorporating the advice
> from your previous email.
>
> I've had some success, in that I can generate a Module object,
> populated
> it with functions and instructions, and print out the resulting
> LLVM IR.
Great!
> But I'm still a little puzzled on how to connect the front end with
> LLVM's backend code generator, I can't seem to figure out how to
> run the
> various optimization and code generation passes.
You need to set up a passmanager or two, populate them with the
passes you want, then tell them to run on the code, when appropriate.
> The one example that seems close to what I want is the llc.cpp source
> file; But when I try to do the same thing in my code, I find that the
> TargetMachineRegistry is empty; And yet I see no code in llc.cpp that
> initializes this, nor do I see #includes or Makefile dependencies
> in the
> llc project that would do this implicitly.
The best example here is llvm-gcc. In particular, the llvm-
backend.cpp file contains the top-level code that sets up the
optimization pipeline and the code generator, and is the one that
runs it at various times.
-Chris
More information about the llvm-dev
mailing list