I want this conversion (from MachineInstr
to MCInst
) in a MachineFunctionPass
.
I know that X86MCInstLower
converts the MachineInstr
to MCInst
. However, initializing X86MCInstLower
requires an instance of X86AsmPrinter
. X86AsmPrinter
is in itself MachineFunctionPass
which requires TargetMachine &
and std::unique_ptr<MCStreamer>
to be initiated. I cannot get TargetMachine
from a MachineFunction
as MachineFunction
only returns const TargetMachine &
. The TargetMachine
constructor also does not have any copy-constructor from const TargetMachine
.
Therefore, I am stuck at this point of conversion. Is there any way to run a registered pass and get its output, from within a MachineFunctionPass
? X86AsmPrinter
is registered under TargetRegistry
with RegisterAsmPrinter
. I wonder if we could utilize that.
There is a mailing list thread regarding this. However, that doesn't address the problem finally.