On Fri, Oct 10, 2014 at 11:03 AM, Boris Boesler <baembel at gmx.de> wrote:
> Hi!
>
> 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.
>
> I implemented the method ::eliminateFrameIndex() similar to the Sparc and
> ARM backend. The method looks like this:
>
> // frame pointer is in reg of class mytarget::ARegsRegClass
> unsigned ScratchReg >
MF.getRegInfo().createVirtualRegister(&mytarget::ARegsRegClass);
> const TargetInstrInfo &TII = *MF.getTarget().getInstrInfo();
> BuildMI(*MI.getParent(), II, dl, TII.get(mytarget::ADD_AReg),
> ScratchReg).addReg(FramePtr).addImm(Offset);
> // Update the original instruction to use the scratch register.
> MI.getOperand(FIOperandNum).ChangeToRegister(ScratchReg, false);
>
> But for the test case
>
> int foo(void)
> {
> int a = 43;
> return(41);
> }
>
> I get the error message "Remaining virtual register operands".
>
> Is something wrong with my method? Did I miss to implement some more
> methods?
>
> Thanks in advance,
> Boris
>
>
Hi, you need to override requiresRegisterScavenging()
and requiresFrameIndexScavenging() in your XXXRegisterInfo class to return
true.
FrameIndex elimination is done after RegAlloc and this tells LLVM to use
the RegisterScavenging to get a new register during frame elimination.
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://lists.llvm.org/pipermail/llvm-dev/attachments/20141010/9a2184f2/attachment.html>