[LLVMdev] Iterator to enumerate machine operands
Chris Lattner
sabre at nondot.org
Mon Aug 1 11:59:13 PDT 2005
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/
More information about the llvm-dev
mailing list