On Sun, 2 Jul 2006, Fernando Magno Quintao Pereira
wrote:> Thank you, chris. But I still do not understand how to insert this move
> instruction :)
You call copyRegToReg, like you are already doing. What you really aren't
understanding is how to pick a regclass, which is a different issue.
> 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?
No, it isn't. What you're basically saying here is that, in the process
of your register allocator, you have discarded information about what
register classes the physical registers used to be in. If you retained
this information, you would have no problem. I suggest you modify your
allocator to retain this information, just like the other extant
allocators do.
> I think I got around this problem of discovering the class of a
> physical register. I am using this code here:
As I mentioned in my previous email, this won't work because physregs can
be in multiple reg classes. For example, if you are trying to copy
between R1 and R2, it's quite possible that R1 is in RC1 and RC2 and that
R2 is in RC2 only. "Picking" RC1 won't work. The safe thing to
do would
be to pick something out of the intersection of the register classes the
registers are in, but computing this on the fly would be horribly
inefficient and building big tables of these would take a bunch of space.
You'd be far better off by not throwing away the information you need
earlier.
-Chris
> 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
>>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>
-Chris
--
http://nondot.org/sabre/
http://llvm.org/