[llvm] r240805 - Add op_values() to iterate over the SDValue operands of an SDNode.
Pete Cooper
peter_cooper at apple.com
Fri Jun 26 11:17:36 PDT 2015
Author: pete
Date: Fri Jun 26 13:17:36 2015
New Revision: 240805
URL: http://llvm.org/viewvc/llvm-project?rev=240805&view=rev
Log:
Add op_values() to iterate over the SDValue operands of an SDNode.
SDNode already had ops() which would iterate over the operands and return
SDUse*. This version instead gets the SDValue's out of the SDUse's so that
we can use foreach in more places.
Reviewed by David Blaikie.
Modified:
llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h
llvm/trunk/lib/Target/AArch64/AArch64ISelLowering.cpp
Modified: llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h?rev=240805&r1=240804&r2=240805&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h (original)
+++ llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h Fri Jun 26 13:17:36 2015
@@ -579,6 +579,23 @@ public:
op_iterator op_end() const { return OperandList+NumOperands; }
ArrayRef<SDUse> ops() const { return makeArrayRef(op_begin(), op_end()); }
+ /// Iterator for directly iterating over the operand SDValue's.
+ struct value_op_iterator
+ : iterator_adaptor_base<value_op_iterator, op_iterator,
+ std::random_access_iterator_tag, SDValue,
+ ptrdiff_t, value_op_iterator *,
+ value_op_iterator *> {
+ explicit value_op_iterator(SDUse *U = nullptr)
+ : iterator_adaptor_base(U) {}
+
+ const SDValue &operator*() const { return I->get(); }
+ };
+
+ iterator_range<value_op_iterator> op_values() {
+ return iterator_range<value_op_iterator>(value_op_iterator(op_begin()),
+ value_op_iterator(op_end()));
+ }
+
SDVTList getVTList() const {
SDVTList X = { ValueList, NumValues };
return X;
Modified: llvm/trunk/lib/Target/AArch64/AArch64ISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AArch64/AArch64ISelLowering.cpp?rev=240805&r1=240804&r2=240805&view=diff
==============================================================================
--- llvm/trunk/lib/Target/AArch64/AArch64ISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/AArch64/AArch64ISelLowering.cpp Fri Jun 26 13:17:36 2015
@@ -1777,8 +1777,7 @@ static bool isExtendedBUILD_VECTOR(SDNod
if (N->getOpcode() != ISD::BUILD_VECTOR)
return false;
- for (unsigned i = 0, e = N->getNumOperands(); i != e; ++i) {
- SDNode *Elt = N->getOperand(i).getNode();
+ for (const SDValue &Elt : N->op_values()) {
if (ConstantSDNode *C = dyn_cast<ConstantSDNode>(Elt)) {
unsigned EltSize = VT.getVectorElementType().getSizeInBits();
unsigned HalfSize = EltSize / 2;
More information about the llvm-commits
mailing list