[llvm] 6b9a706 - Add front/back accessors to indexed_accessor_range.
River Riddle via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 29 22:44:25 PDT 2020
Author: River Riddle
Date: 2020-06-29T22:41:15-07:00
New Revision: 6b9a706200cbb27e5e863cfd41fb3684ee616e23
URL: https://github.com/llvm/llvm-project/commit/6b9a706200cbb27e5e863cfd41fb3684ee616e23
DIFF: https://github.com/llvm/llvm-project/commit/6b9a706200cbb27e5e863cfd41fb3684ee616e23.diff
LOG: Add front/back accessors to indexed_accessor_range.
These map to the similar accessors on ArrayRef and other random access containers.
This fixes a compilation error on MLIR ODS for variadic operands/results, which relied on the availability of front in certain situations.
Added:
Modified:
llvm/include/llvm/ADT/STLExtras.h
mlir/test/lib/Dialect/Test/TestOps.td
Removed:
################################################################################
diff --git a/llvm/include/llvm/ADT/STLExtras.h b/llvm/include/llvm/ADT/STLExtras.h
index 1bc4c0caa4d4..b2e709f7272f 100644
--- a/llvm/include/llvm/ADT/STLExtras.h
+++ b/llvm/include/llvm/ADT/STLExtras.h
@@ -1121,6 +1121,14 @@ class indexed_accessor_range_base {
assert(index < size() && "invalid index for value range");
return DerivedT::dereference_iterator(base, index);
}
+ ReferenceT front() const {
+ assert(!empty() && "expected non-empty range");
+ return (*this)[0];
+ }
+ ReferenceT back() const {
+ assert(!empty() && "expected non-empty range");
+ return (*this)[size() - 1];
+ }
/// Compare this range with another.
template <typename OtherT> bool operator==(const OtherT &other) const {
diff --git a/mlir/test/lib/Dialect/Test/TestOps.td b/mlir/test/lib/Dialect/Test/TestOps.td
index 6aa18c1324bd..bc8f2ff3f818 100644
--- a/mlir/test/lib/Dialect/Test/TestOps.td
+++ b/mlir/test/lib/Dialect/Test/TestOps.td
@@ -124,6 +124,12 @@ def MixedNormalVariadicOperandOp : TEST_Op<
Variadic<AnyTensor>:$input3
);
}
+def VariadicWithSameOperandsResult :
+ TEST_Op<"variadic_with_same_operand_results",
+ [SameOperandsAndResultType]> {
+ let arguments = (ins Variadic<AnySignlessInteger>:$operands);
+ let results = (outs AnySignlessInteger:$result);
+}
//===----------------------------------------------------------------------===//
// Test Results
More information about the llvm-commits
mailing list