LLVM IR to ISA

Hello,

After instruction selection I would like to print out the selected instructions with the corresponding LLVM instructions. Something like this:

LLVM Instruction -> { MCInst,
                                    MCInst,
                                    MCInst
                                 }

Is there a build-in way to do it?

Thank you

Instruction selection happens on a basic block basis. You can dump the IR basic block and the machine basic block relatively easily, but N IR instructions may correspond to M machine instructions. There's no simple mapping from one IR instruction to multiple native instructions. For example, consider a GEP followed by a load. On x86 or ARM, this will typically be folded into a single instruction. Similarly, a ptrtoint, followed by a sequence of arithmetic, followed by an inttoptr, followed by a load or store may become a single instruction. The various SelectionDAG phases will split and combine instructions in various ways.

David