Best place to implement support for a custom binary format?

Hi guys,

I was looking into reusing the Clang frontend as well as LLVM’s optimization passes while trying to produce binaries in a custom executable file format, later to be executed by a VM on an embedded device. My original intent was to recursively walk through the LLVM tree and output the custom byte-codes, data space entries, etc… to disk after the optimization passes are run. Is there any better place to do this? Implementing a custom target seems like overkill for my purpose.

Thanks,

Matt