On Fri, Apr 13, 2012 at 03:32:01AM +1200, James Miller
wrote:> * Tom Stellard <thomas.stellard at amd.com> [2012-04-12 10:54:17
-0400]:
>
> > On Fri, Apr 13, 2012 at 02:41:58AM +1200, James Miller wrote:
> > > Hi, I've just started working with LLVM, and have just
finished the
> > > Kaleidoscope tutorial. Everything is fine, however I am finding
it
> > > difficult to find any information on how to use the /library/ to
> > > generate native object files. I'm assume that it should be
possible, but
> > > almost all of the information on llvm.org and beyond is centered
around
> > > either JIT compilation or writing new backends for codegen.
> > >
> > > If somebody could point me in the right direction for this, I
would be
> > > most grateful.
> > >
> >
> > Take a look at the tools/llc/llc.cpp file, it is a pretty good example
> > of how to do this.
> >
> > -Tom
cc'ing llvmdev
>
> Thanks for that, it is a good reference for what I want.
>
> A couple more things: just to make sure I'm understanding this right,
> native codegen is implemented as a pass, right? To be added to a
> PassManager? You then run the PassManager on the module and it generates
> machine code?
Yes, this is basically how it works. Emitting the code is just one
pass, but the entire process of converting LLVM IR to machine code is
implemented in several passes.
> Also, Target.addPassesToEmitFile() seems to only take 4
> arguments according to doxygen docs, but the call in llc.cpp takes 5,
> I've figured out that the extra argument is the optimization setting,
> but the lack of information in docs is confusing.
>
Make sure that the docs you are looking at match the version of LLVM
that you are using. addPassesToEmitFile currently takes 4 arguments,
but it used to take 5.
-Tom