[PATCH] Add iterator_adaptor to iterate over SDNode operand SDNode's

Pete Cooper peter_cooper at apple.com
Thu Jun 25 14:30:43 PDT 2015


Hi David

Currently the only SDNode iterator over operands does so with SDUse*.  Users frequently then call getNode() on the operand.

This patch adds an iterator to SDNode which returns the SDNode of the operand.  This allows more patterns to be converted to foreach.  It is based on value_op_iterator which I found in User.h.

For now i’ve only used it in a single place, but I found a bunch more in DAGCombiner for example which should be applicable.  I would convert those in a later commit assuming you are ok with this solution.

BTW, been trying to work out if there would ever be a good solution for an iterator combined with isa<> or dyn_cast<>.  If you look at the code this patch touches in AArch64ISelLowering, it is immediately followed by a dyn_cast.  I’d really like to find a clean way to fold that it to the foreach loop, i.e.,

for (auto *C : dyn_cast<ConstantSDNode>(N->op_nodes()))

just a thought, but thats unrelated to this patch for now.

Cheers,
Pete

-------------- next part --------------
A non-text attachment was scrubbed...
Name: op_iterator.patch
Type: application/octet-stream
Size: 2036 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150625/9a9acca4/attachment.obj>


More information about the llvm-commits mailing list