I'm having trouble with virtual registers/register allocation in my back-end. Basically the FastRegAlloc pass is generating calls to storeToStackSlot and loadFromStackSlot, in which we build new machine instructions, which are then _not_ processed by the reg allocator. I understand that BuildMI is changing the list of MachInst. that the allocator is iterating over, but we need to have a new virtual register as part of the stack store process since we don't have indirect adressing. Should we be creating a physical register directly somehow, or can we perhaps signal to the allocator that the basic block's contents are updated? <br>
<br>Below is our storeRegToStackSlot, the ADDri instruction is transformed into a copy-add pair in eliminateFrameIndex.<br><br>void OurTargetInstrInfo::storeRegToStackSlot(MachineBasicBlock &MBB,<br>                                          MachineBasicBlock::iterator MI,<br>
                                          unsigned SrcReg, bool isKill, int FrameIdx,<br>                                          const TargetRegisterClass *RC, <br>                                          const llvm::TargetRegisterInfo*) const {<br>
  DebugLoc DL;<br>  if (MI != MBB.end()) DL = MI->getDebugLoc();<br>  MachineFunction &MF = *MBB.getParent();<br>  MachineFrameInfo &MFI = *MF.getFrameInfo();<br><br>  MachineMemOperand *MMO =<br>    MF.getMachineMemOperand(PseudoSourceValue::getFixedStack(FrameIdx),<br>
                            MachineMemOperand::MOStore, 0,<br>                            MFI.getObjectSize(FrameIdx),<br>                            MFI.getObjectAlignment(FrameIdx));<br>  <br>  unsigned tmpVReg = MF.getRegInfo().createVirtualRegister(OURTARGET::IntRegsRegisterClass);<br>
  MachineInstr* mi = BuildMI(MBB, MI, DL, get(OURTARGET::ADDri), tmpVReg).addFrameIndex(FrameIdx).addImm(0);<br>  BuildMI(MBB, MI, DL, get(OURTARGET::STORE)).addReg(tmpVReg).addReg(SrcReg).addMemOperand(MMO);<br>}<br><br>
Thanks a lot!<br>Per<br>