Iterator to enumerate machine operands

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Iterator to enumerate machine operands

Tzu-Chien Chiu
I want to enumerate all the operands of a machine instruction, but the
iterator seems to skip everything except virtual registers. Is this by
design?

MachineInstr.h

<code>
 template<class MITy, class VTy>
  class ValOpIterator : public forward_iterator<VTy, ptrdiff_t> {
    void skipToNextVal() {
      while (i < MI->getNumOperands() &&
             !( (MI->getOperand(i).getType() ==
MachineOperand::MO_VirtualRegister ||
                 MI->getOperand(i).getType() == MachineOperand::MO_CCRegister)
                && MI->getOperand(i).getVRegValue() != 0))
        ++i;
    }
</code>

--
Tzu-Chien Chiu,
3D Graphics Hardware Architect
<URL:http://www.csie.nctu.edu.tw/~jwchiu>

_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: Iterator to enumerate machine operands

Chris Lattner
On Sat, 30 Jul 2005, Tzu-Chien Chiu wrote:
> I want to enumerate all the operands of a machine instruction, but the
> iterator seems to skip everything except virtual registers. Is this by
> design?

Please don't use that, that is SparcV9 specific.  Instead, do something
like this:

   MachineInstr *MI = ...
   for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i)
     ... MI->getOperand(i) ...

-Chris

> MachineInstr.h
>
> <code>
> template<class MITy, class VTy>
>  class ValOpIterator : public forward_iterator<VTy, ptrdiff_t> {
>    void skipToNextVal() {
>      while (i < MI->getNumOperands() &&
>             !( (MI->getOperand(i).getType() ==
> MachineOperand::MO_VirtualRegister ||
>                 MI->getOperand(i).getType() == MachineOperand::MO_CCRegister)
>                && MI->getOperand(i).getVRegValue() != 0))
>        ++i;
>    }
> </code>
>
>

-Chris

--
http://nondot.org/sabre/
http://llvm.org/

_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev