[LLVMdev] Inserting move instruction
Fernando Magno Quintao Pereira
fernando at CS.UCLA.EDU
Sun Jul 2 16:09:12 PDT 2006
> On Sun, 2 Jul 2006, Fernando Magno Quintao Pereira wrote:
>
> > 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.
>
> You can't do it with this information. In some higher context you should
> have information about what register class the physreg is to be
> interpreted as. Physregs can be in multiple register classes.
>
> All of the register allocators call this method, so there are plenty of
> examples.
>
> -Chris
Thank you, chris. But I still do not understand how to insert this move
instruction :) I have the machine function, the basic block, and the
unsigned descriptors of the source and destiny register. With this
information is possible to insert a move, considering that the source
and destiny are physical registers? The example that I could find, in
the phi-elimination pass, expects virtual registers. But I am eliminating
phi functions after register allocation has been performed. I would like
to know if there is a simple way to discover the class of a physical
register given MachineFunction and MachineBasicBlock. Could you point me
an example in the code of one of the register allocators?
Thanks a lot,
Fernando
More information about the llvm-dev
mailing list