Fernando Magno Quintao Pereira
2007-Feb-22 07:17 UTC
[LLVMdev] Reference to recently created move
Hey, guys, I am creating some move instructions with MRegisterInfo::copyRegToReg. How do I get a pointer to the instruction that I just created? Is there a way to do something like: // mbb is MachineBasicBlock, reg_info is MRegisterInfo MachineBasicBlock::iterator iter = mbb.getFirstTerminator(); reg_info->copyRegToReg(mbb, iter, dst, src, rc); iter--; (???) MachineInstr * new_move_instruction = iter; (???) This does not work though. Thank you, Fernando
copyRegToReg() always insert the move instruction before "iter". Just use prior(iter) after the insertion to reference the newly created move instruction. Evan On Feb 21, 2007, at 11:17 PM, Fernando Magno Quintao Pereira wrote:> > Hey, guys, I am creating some move instructions with > MRegisterInfo::copyRegToReg. How do I get a pointer to the instruction > that I just created? Is there a way to do something like: > > // mbb is MachineBasicBlock, reg_info is MRegisterInfo > > MachineBasicBlock::iterator iter = mbb.getFirstTerminator(); > > reg_info->copyRegToReg(mbb, iter, dst, src, rc); > > iter--; (???) > > MachineInstr * new_move_instruction = iter; (???) > > This does not work though. > > Thank you, > > Fernando > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Fernando Magno Quintao Pereira
2007-Feb-22 20:22 UTC
[LLVMdev] Reference to recently created move
Thanks, Evan. Actually, the previous code is working. I had got a segfault for some reason, but it was not because of the dereferencing. I have figured it out now. Fernando> copyRegToReg() always insert the move instruction before "iter". Just > use prior(iter) after the insertion to reference the newly created > move instruction. > > Evan > On Feb 21, 2007, at 11:17 PM, Fernando Magno Quintao Pereira wrote: > >> >> Hey, guys, I am creating some move instructions with >> MRegisterInfo::copyRegToReg. How do I get a pointer to the instruction >> that I just created? Is there a way to do something like: >> >> // mbb is MachineBasicBlock, reg_info is MRegisterInfo >> >> MachineBasicBlock::iterator iter = mbb.getFirstTerminator(); >> >> reg_info->copyRegToReg(mbb, iter, dst, src, rc); >> >> iter--; (???) >> >> MachineInstr * new_move_instruction = iter; (???) >> >> This does not work though. >> >> Thank you, >> >> Fernando >> _______________________________________________ >> LLVM Developers mailing list >> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >