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

Jeremy Lakeman via llvm-dev llvm-dev at lists.llvm.org
Thu Sep 6 23:39:54 PDT 2018


To really reduce boilerplate you might be able to define the right macros and then #include include/llvm/IR/Instruction.def.

On 6 September 2018 at 23:16, Philip Pfaffe via llvm-dev < llvm-dev at lists.llvm.org> wrote:

Hi,

InstVisitor will give you that switch. Derive from that and you get to handle the different instruction types appropriately. Cheers, Philip On Thu, Sep 6, 2018 at 3:41 PM Gleb Popov via llvm-dev <_ _llvm-dev at lists.llvm.org> wrote:

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.


LLVM Developers mailing list llvm-dev at lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev


LLVM Developers mailing list llvm-dev at lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20180907/d302a8db/attachment.html>



More information about the llvm-dev mailing list