[LLVMdev] Re: Directly generating binary file

Chris Lattner sabre at nondot.org
Wed Mar 1 11:21:44 PST 2006

On Tue, 28 Feb 2006, Vladimir Prus wrote:
>>> The TargetMachine class has a method 'addPassesToEmitMachineCode', that's
>>> suitable for that, but that method also requires an instance of
>>> MachineCodeEmitter.
>> Actually, you probably want to plug into the addPassesToEmitFile API, when
>> FileType is set to ObjectFile.  X86TargetMachine::addPassesToEmitFile
>> demonstrates how to do this.
> Ok. Note, however, that online HTML docs for "llc", as well as "llc.pod" in
> the current CVS don't mention the "filetype" option that is used to control
> file format.

Currently, no targets support that option, so it's basically an internal 
interface still.

> And, should 'addPassesToEmitMachineCode' method be declared deprecated?

It is used for the JIT.

>> Alternatively, you could side step all of this and write your own .o file
>> writer that doesn't use the MachineCodeEmitter interfaces at all.  If this
>> is easiest, go for it.
> So far this looks the simplest approach. Especially sincelooking at
> ELFCodeEmitter, I see quite a bunch of unimplemented methods.


>> Note that *some* assembler format is useful for debugging, writting
>> regression tests, etc.
> Sure, I plan to have some format that will be output by disassembler, but
> don't plan to ever read that format ;-)

Makes sense! :)



More information about the llvm-dev mailing list