[LLVMdev] Inserting move instruction

Fernando Magno Quintao Pereira fernando at CS.UCLA.EDU
Sun Jul 2 16:47:58 PDT 2006


Hi, again,

    I think I got around this problem of discovering the class of a
physical register. I am using this code here:

void PhiDeconstruction_Fer::add_move
                        (MachineBasicBlock & mbb, unsigned src, unsigned
dst) {
    MachineBasicBlock::iterator iter = mbb.getFirstTerminator();
    const MRegisterInfo * reg_info =
                       this->machine_function->getTarget().getRegisterInfo();

    // TODO: verify if does not causes incorrect allocation:
    for(MRegisterInfo::regclass_iterator rcii = reg_info->regclass_begin(),
                       rcie = reg_info->regclass_end(); rcii != rcie; ++rcii) {
        if( (*rcii)->contains(dst) ) {
            rc = * rcii;
        }
    }

    reg_info->copyRegToReg(mbb, iter, dst, src, rc);
}

Fernando

> > 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
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>



More information about the llvm-dev mailing list