<div dir="ltr"><div dir="ltr"><div>Hello.</div><div><br></div><div>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.</div><div><br></div><div>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.</div><div><br></div><div>Any ideas how to do that easier way? How much of existing LLVM code can I reuse?<br></div><div><br></div><div>Thanks in advance.<br></div></div></div>