[llvm-dev] How to get assembly opcode mnemonic(s) corresponding to a MachineInstr?
David Chisnall via llvm-dev
llvm-dev at lists.llvm.org
Sat Feb 4 17:21:29 PST 2017
On 4 Feb 2017, at 14:19, Radhika via llvm-dev <llvm-dev at lists.llvm.org> wrote:
> I'd like to modify MachineBasicBlock contents within a
> MachineFunctionPass on the basis of how many CPU cycles the assembly
> instructions corresponding to the MBB take. I'm using the AVR backend
> and the number of CPU cycles every AVR assembly operation takes is
> openly available.
> Is there any straightforward way of getting the opcode mnemonics
> corresponding to a MachineInstr? I've gone through this thread
> and I understand I need to modify the AsmPrinter or InstPrinter in
> some way, but am not sure how.
I think that you actually want to do the opposite of what you’re asking: identify the opcode of a MCInstrDesc that corresponds to a particular mnemonic. Unfortunately, there is no way of doing this other than looking in the backend’s instruction definitions. Attempting to print the instruction using the AsmPrinter and then parse the mnemonic is almost certainly not the right way of doing anything (though it would help if you explained what you are trying to do).
More information about the llvm-dev