[LLVMdev] MachineRegisterInfo use_iterator/reg_iterator?

Quentin Colombet qcolombet at apple.com
Thu Sep 25 10:51:11 PDT 2014


Hi Cheng-Chih,

On Sep 25, 2014, at 9:14 AM, Yang, Cheng-Chih <Cheng-Chih.Yang at amd.com> wrote:

> Hi folks,
>  
> I would like to find out the machine instructions that use some given registers in the reverse order, and I came across these iterators (use_iterator/reg_iterator). However, there are two things I noticed:
>  
> 1) These iterators seem to traverse the machine function a bit differently from what I get from the machine function dump. In other words, the use_iterator list is not constructed in the same order as the machine function?

Yes, the use_iterator list is not constructed in the same order as the machine function.

> Maybe from the order that DAG is constructed?

No, this is not the case either.
The list is constructed via calls to MachineInstr::setReg (which calls MachineRegisterInfo::addRegOperandToUseList if you are interested by the details), which could basically occur anywhere in the backend.
That said, the main users of this interface is the VirtRegMap pass, which walks through the function and set the register along the way. Therefore, most of the use_iterator should be in the order you want, but not all and more importantly, we do not ensure that this ordering is fulfilled.

>  
> 2) Is there a way to go backward with these two iterators? For example, from use_end() to use_begin() with some decrement operator?

AFAIK, no, because we did not need so far to traverse them in a specific order.

What are you trying to achieve?

Cheers,
-Quentin
>  
> I was wondering if 1) and 2) are true or just there’s something I missed.
>  
> Thanks!
> Cheng-Chih
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140925/b4e28e84/attachment.html>


More information about the llvm-dev mailing list