|
18 | 18 | #define SWIFT_SIL_SILVALUE_H
|
19 | 19 |
|
20 | 20 | #include "swift/Basic/Range.h"
|
| 21 | +#include "swift/Basic/ArrayRefView.h" |
21 | 22 | #include "swift/SIL/SILNode.h"
|
22 | 23 | #include "swift/SIL/SILType.h"
|
23 | 24 | #include "llvm/ADT/ArrayRef.h"
|
@@ -419,64 +420,10 @@ class Operand {
|
419 | 420 | ///
|
420 | 421 | /// The intent is that this should basically act exactly like
|
421 | 422 | /// ArrayRef except projecting away the Operand-ness.
|
422 |
| -class OperandValueArrayRef { |
423 |
| - ArrayRef<Operand> Operands; |
424 |
| -public: |
425 |
| - explicit OperandValueArrayRef(ArrayRef<Operand> operands) |
426 |
| - : Operands(operands) {} |
427 |
| - |
428 |
| - /// A simple iterator adapter. |
429 |
| - class iterator : public std::iterator<std::forward_iterator_tag, |
430 |
| - SILValue, ptrdiff_t> { |
431 |
| - const Operand *Ptr; |
432 |
| - public: |
433 |
| - iterator() = default; |
434 |
| - iterator(const Operand *ptr) : Ptr(ptr) {} |
435 |
| - SILValue operator*() const { assert(Ptr); return Ptr->get(); } |
436 |
| - SILValue operator->() const { return operator*(); } |
437 |
| - iterator &operator++() { ++Ptr; return *this; } |
438 |
| - iterator operator++(int) { iterator copy = *this; ++Ptr; return copy; } |
439 |
| - |
440 |
| - friend bool operator==(iterator lhs, iterator rhs) { |
441 |
| - return lhs.Ptr == rhs.Ptr; |
442 |
| - } |
443 |
| - friend bool operator!=(iterator lhs, iterator rhs) { |
444 |
| - return lhs.Ptr != rhs.Ptr; |
445 |
| - } |
446 |
| - }; |
447 |
| - |
448 |
| - iterator begin() const { return iterator(Operands.begin()); } |
449 |
| - iterator end() const { return iterator(Operands.end()); } |
450 |
| - size_t size() const { return Operands.size(); } |
451 |
| - bool empty() const { return Operands.empty(); } |
452 |
| - |
453 |
| - SILValue front() const { return Operands.front().get(); } |
454 |
| - SILValue back() const { return Operands.back().get(); } |
455 |
| - |
456 |
| - SILValue operator[](unsigned i) const { return Operands[i].get(); } |
457 |
| - OperandValueArrayRef slice(unsigned begin, unsigned length) const { |
458 |
| - return OperandValueArrayRef(Operands.slice(begin, length)); |
459 |
| - } |
460 |
| - OperandValueArrayRef slice(unsigned begin) const { |
461 |
| - return OperandValueArrayRef(Operands.slice(begin)); |
462 |
| - } |
463 |
| - OperandValueArrayRef drop_back() const { |
464 |
| - return OperandValueArrayRef(Operands.drop_back()); |
465 |
| - } |
466 |
| - |
467 |
| - bool operator==(const OperandValueArrayRef RHS) const { |
468 |
| - if (size() != RHS.size()) |
469 |
| - return false; |
470 |
| - for (auto L = begin(), LE = end(), R = RHS.begin(); L != LE; ++L, ++R) |
471 |
| - if (*L != *R) |
472 |
| - return false; |
473 |
| - return true; |
474 |
| - } |
475 |
| - |
476 |
| - bool operator!=(const OperandValueArrayRef RHS) const { |
477 |
| - return !(*this == RHS); |
478 |
| - } |
479 |
| -}; |
| 423 | +inline SILValue getSILValueType(const Operand &op) { |
| 424 | + return op.get(); |
| 425 | +} |
| 426 | +typedef ArrayRefView<Operand,SILValue,getSILValueType> OperandValueArrayRef; |
480 | 427 |
|
481 | 428 | /// An iterator over all uses of a ValueBase.
|
482 | 429 | class ValueBaseUseIterator : public std::iterator<std::forward_iterator_tag,
|
|
0 commit comments