<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Oct 10, 2014 at 11:03 AM, Boris Boesler <span dir="ltr"><<a href="mailto:baembel@gmx.de" target="_blank">baembel@gmx.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Hi!<br>
<br>
 I started writing a LLVM backend for a custom architecture. I have some register and instruction .td files and some other files/classes like a MCStreamer for assembler output. At the moment I can compile some empty programs so far.<br>
<br>
 I implemented the method ::eliminateFrameIndex() similar to the Sparc and ARM backend. The method looks like this:<br>
<br>
// frame pointer is in reg of class mytarget::ARegsRegClass<br>
unsigned ScratchReg = MF.getRegInfo().createVirtualRegister(&mytarget::ARegsRegClass);<br>
const TargetInstrInfo &TII = *MF.getTarget().getInstrInfo();<br>
BuildMI(*MI.getParent(), II, dl, TII.get(mytarget::ADD_AReg), ScratchReg).addReg(FramePtr).addImm(Offset);<br>
// Update the original instruction to use the scratch register.<br>
MI.getOperand(FIOperandNum).ChangeToRegister(ScratchReg, false);<br>
<br>
 But for the test case<br>
<br>
int foo(void)<br>
{<br>
  int a = 43;<br>
  return(41);<br>
}<br>
<br>
 I get the error message "Remaining virtual register operands".<br>
<br>
 Is something wrong with my method? Did I miss to implement some more methods?<br>
<br>
Thanks in advance,<br>
Boris<br>
<br></blockquote><div><br></div><div>Hi, you need to override requiresRegisterScavenging() and requiresFrameIndexScavenging() in your XXXRegisterInfo class to return true.</div><div>FrameIndex elimination is done after RegAlloc and this tells LLVM to use the RegisterScavenging to get a new register during frame elimination. </div><div><br></div></div></div></div>