[CodeGen] Read/Write Machine IR from/to Persistent File

Dear LLVM developers,

Just as LLVM IR can be read/write via persistent bitcode (*.bc *.ll) files, is there any similar implementation in LLVM to read/write Machine IR (MIR) via a persistent file?

If not and I would like to add it (e.g. for ARM or RISC-V), could you direct me materials and/or LLVM source code modules where I should start with?

Best Regards,
Lele Ma

Yes, http://llvm.org/docs/MIRLangRef.html#id12

Usually you use -stop-before=passname or -stop-after=passname to get some MIR at a relevant point. Note that currently not all information tracked is really serialized, especially target specific MachineFunctionInfo. Some targets partially implement this, but there are still a lot of gaps.

Also note nothing about MIR is remotely stable, so this may differ from what you mean by “persistent”

-Matt

Dear Matthew,

Yes, http://llvm.org/docs/MIRLangRef.html#id12

Usually you use -stop-before=passname or -stop-after=passname to get some MIR at a relevant point. Note that currently not all information tracked is really serialized, especially target specific MachineFunctionInfo. Some targets partially implement this, but there are still a lot of gaps.

Thanks for your prompt response. That is helpful.

Also note nothing about MIR is remotely stable, so this may differ from what you mean by “persistent”

Could you explain a little bit more about what do you mean by “remotely stable” ? Can the serialized YAML MIR be compiled into a final executable?

Lele