[LLVMdev] Could LLVM help me?

Misha Brukman brukman at uiuc.edu
Mon Dec 27 10:41:21 PST 2004

On Mon, Dec 27, 2004 at 12:37:59PM -0600, Tanya Lattner wrote:
> >1. I wrote a very simple backend, but I dont know how to tell the
> >llvm compiler to use it.  I found something in "llc --help", it says
> >that I can use -march=BACKEND. But it only can use X86, sparcev9 and
> >powerpc. The skeleton looks like for custom use, but I dnot know how
> >to use it??
> You need to use -load or link it in statically to the llc executable.
> If you have done this you should see your backend option with -help.

In addition to what Tanya said, you need something like this, taken from

// Register the target.
RegisterTarget<X86TargetMachine> X("x86", "  IA-32 (Pentium and above)");
This will add an option "-march=x86" to llc.
> >2.  I dont know how to generate the "machine code", which I mean is
> >the code looks like "01001110101010100010....". All I got was the
> >"assembly code", not machine code.
> Usually you use a system assembler to do this. The other way to do it
> is to implement the JIT code emitter interface.

Just to clarify: a JIT compiler will write out code to MEMORY, which is
probably not what you want for your new test processor.  The JIT
compiler does have support for relocations, so it is possible (though
not currently implemented) to have LLVM produce object files (machine
code) to DISK instead of memory.  This will require some work, though.

Misha Brukman :: http://misha.brukman.net :: http://llvm.cs.uiuc.edu

More information about the llvm-dev mailing list