> > Thank you Chris. I will try to implement the TwoAddress pass to run on > > machine code. Why it has not been originally implemented to run on > > machine code? > > I'm not sure what you mean. It definitely does run on machine code.I was thinking that it only transformed instructions with virtual registers because of this code in the TwoAddressInstructionPass.cpp: unsigned regA = mi->getOperand(0).getReg(); unsigned regB = mi->getOperand(1).getReg(); assert(MRegisterInfo::isVirtualRegister(regA) && MRegisterInfo::isVirtualRegister(regB) && "cannot update physical register live information"); By machine code I meant code with virtual registers, instead of machine (physical) registers; not the passes on machine functions/machine basic blocks. Fernando
On Mon, 26 Jun 2006, Fernando Magno Quintao Pereira wrote:>>> Thank you Chris. I will try to implement the TwoAddress pass to run on >>> machine code. Why it has not been originally implemented to run on >>> machine code? >> >> I'm not sure what you mean. It definitely does run on machine code. > > I was thinking that it only transformed instructions with virtual > registers because of this code in the TwoAddressInstructionPass.cpp: > > unsigned regA = mi->getOperand(0).getReg(); > unsigned regB = mi->getOperand(1).getReg(); > > assert(MRegisterInfo::isVirtualRegister(regA) && > MRegisterInfo::isVirtualRegister(regB) && > "cannot update physical register live information"); > > By machine code I meant code with virtual registers, instead of machine > (physical) registers; not the passes on machine functions/machine basic > blocks.Right. Two address instructions can only use virtual registers, not physical registers. -Chris -- nondot.org/sabre llvm.org
Dear llvmers, I am trying to insert a move instruction where both source and destination registers are physical registers. How is the code for this? I tried this one here: void PhiDeconstruction_Fer::add_move ( MachineFunction & mf, MachineBasicBlock & mbb, unsigned src, unsigned dst ) { MachineBasicBlock::iterator iter = mbb.getFirstTerminator(); const TargetRegisterClass *rc = mf.getSSARegMap()->getRegClass(dst); const MRegisterInfo * reg_info = mf.getTarget().getRegisterInfo(); reg_info->copyRegToReg(mbb, iter, dst, src, rc); } But the getRegClass method seems to expect a virtual register. Could someone fix this code for me? I could not find an example in the source of LLVM. Thank you very much, Fernando