[LLVMdev] Please add .o writer example to next release
Nathan Jeffords
blunted2night at gmail.com
Fri Feb 18 09:18:38 PST 2011
this is function I use to emit an object file:
void output_object (llvm::Module * Module, llvm::TargetMachine * Target,
llvm::raw_ostream & Output)
{
llvm::formatted_raw_ostream fOutput (Output);
FunctionPassManager Passes(Module);
Passes.add(new TargetData (*Target->getTargetData()));
if (Target->addPassesToEmitFile(Passes, fOutput,
llvm::TargetMachine::CGFT_ObjectFile, llvm::CodeGenOpt::None))
throw std::runtime_error ("bad voodoo
(Target->addPassesToEmitFile)");
Passes.doInitialization();
for (llvm::Module::iterator I = Module->begin(), E = Module->end(); I !=
E; ++I)
if (!I->isDeclaration())
Passes.run(*I);
Passes.doFinalization();
}
On Fri, Feb 18, 2011 at 8:33 AM, Óscar Fuentes <ofv at wanadoo.es> wrote:
> Jochen Wilhelmy <j.wilhelmy at arcor.de> writes:
>
> > Is it possible that you add an example how to write a .o with llvm?
>
> +1
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20110218/8c750353/attachment.html>
More information about the llvm-dev
mailing list