[LLVMdev] How to emit a simple stream of machine code.

Tom Stellard tstellar at gmail.com
Wed Aug 10 11:26:07 PDT 2011


Hi,

I am working on an LLVM backend for GPUs, and I would like to be able
to emit a very simple byte stream of machine code, so that it can be
fed directly into the GPU.  I don't need anything fancy, just the raw
machine code, one instruction after another.  I think I've already
implemented everything in the backend that is required to do this, but
I'm not sure how to get a pointer to the emitted machine code stream
so I can send it to the GPU.  I'm guessing that I need to use the
function addPassesToEmitMachineCode(PassManagerBase &PM,JITCodeEmitter
&JCE, CodeGenOpt::Level OptLevel, bool DisableVerify), but I'm not
sure how to extract the code from the JITCodeEmitter, or if this is
even the right place to start.  What is the best way for me to
accomplish this?

Thanks,
Tom



More information about the llvm-dev mailing list