I'm trying to clone a MachineInstr in the AsmPrinter::EmitInstruction, Here is the code: void EsenciaAsmPrinter::EmitInstruction(const MachineInstr *MI) { const MachineFunction *MF = MI->getParent()->getParent(); MachineInstr *CloneMI = MF->CloneMachineInstr(MI); ... ... } The problem is that MF is a const and CloneMachineInstr expects a non-const. Does anybody know if there is a way to create a copy of a given MachineInstr? Any help is appreciated. -- Rail Shafigulin Software Engineer Esencia Technologies -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20151202/a1b8ac69/attachment.html>
Ziqiang Patrick Huang via llvm-dev
2015-Dec-02 23:21 UTC
[llvm-dev] Cloning a MachineInstr
There is a getParent() function in MachineBasicBlock that returns non-const MachineFunction. Patrick 2015-12-02 18:12 GMT-05:00 Rail Shafigulin via llvm-dev < llvm-dev at lists.llvm.org>:> I'm trying to clone a MachineInstr in the AsmPrinter::EmitInstruction, > Here is the code: > > void EsenciaAsmPrinter::EmitInstruction(const MachineInstr *MI) { > const MachineFunction *MF = MI->getParent()->getParent(); > MachineInstr *CloneMI = MF->CloneMachineInstr(MI); > ... > ... > } > > The problem is that MF is a const and CloneMachineInstr expects a > non-const. Does anybody know if there is a way to create a copy of a given > MachineInstr? > > Any help is appreciated. > > -- > Rail Shafigulin > Software Engineer > Esencia Technologies > > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20151202/834ac806/attachment.html>
On Wed, Dec 2, 2015 at 3:21 PM, Ziqiang Patrick Huang < ziqiang.huang at duke.edu> wrote:> There is a getParent() function in MachineBasicBlock that returns > non-const MachineFunction. > > Patrick >The problem is that in void EscalaAsmPrinter::EmitInstruction(const MachineInstr *MI), MI is a const. So whenever I call MI->getParent()->getParent() I get a const method. Is there a different way to clone a MachineInstr? -- Rail Shafigulin Software Engineer Esencia Technologies -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20151202/186ac037/attachment.html>
> On Dec 2, 2015, at 3:12 PM, Rail Shafigulin via llvm-dev <llvm-dev at lists.llvm.org> wrote: > > I'm trying to clone a MachineInstr in the AsmPrinter::EmitInstruction, Here is the code: > > void EsenciaAsmPrinter::EmitInstruction(const MachineInstr *MI) { > const MachineFunction *MF = MI->getParent()->getParent(); > MachineInstr *CloneMI = MF->CloneMachineInstr(MI); > ... > ... > } > > The problem is that MF is a const and CloneMachineInstr expects a non-const. Does anybody know if there is a way to create a copy of a given MachineInstr?What are you trying to achieve in the end? — Mehdi
> What are you trying to achieve in the end? > > — > Mehdi > >I need to insert extra NOP instructions into the bundle or at least generate a few extra ones during the assembly generation. -- Rail Shafigulin Software Engineer Esencia Technologies -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20151202/67640fdb/attachment.html>
Seemingly Similar Threads
- Unable to clone an instruction in AsmPrinter::EmitInstruction
- [LLVMdev] Passing llc options to Clang
- [LLVMdev] How to specify displacement range of a target instruction to llc
- Convert MachineInstr to MCInst in AsmPrinter.cpp
- [LLVMdev] Getting basic block address offset from its parent function