[llvm-dev] Serializing LLVM IR in custom fashion (original) (raw)

Gleb Popov via llvm-dev llvm-dev at lists.llvm.org
Thu Sep 6 06:40:58 PDT 2018


Hello.

I need to write a pass that converts a whole LLVM module into a bytecode for some other VM. VM's instructions resemble LLVM ones pretty much, so it is almost 1-to-1 translation. Basically, I need to do what BitWriterPass does, but using different format for the resulting bytecode.

The obvious solution is just to iterate over all Instructions and serialize them using giant switch(i->getOpcode()), however this involves writing much boilerplate code. And I would eventually need to write a deserializer too, so that doubles the boilerplate work.

Any ideas how to do that easier way? How much of existing LLVM code can I reuse?

Thanks in advance. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20180906/6dfc7c7b/attachment.html>



More information about the llvm-dev mailing list