[llvm] aaacd8c - Add llvm::equal convenient wrapper for ranges around std::equal
Mehdi Amini via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 27 17:10:42 PDT 2021
Author: Mehdi Amini
Date: 2021-07-28T00:10:22Z
New Revision: aaacd8c40622f11f9f98c1a33373f97437e228d6
URL: https://github.com/llvm/llvm-project/commit/aaacd8c40622f11f9f98c1a33373f97437e228d6
DIFF: https://github.com/llvm/llvm-project/commit/aaacd8c40622f11f9f98c1a33373f97437e228d6.diff
LOG: Add llvm::equal convenient wrapper for ranges around std::equal
Differential Revision: https://reviews.llvm.org/D106913
Added:
Modified:
llvm/include/llvm/ADT/STLExtras.h
mlir/include/mlir/IR/OpBase.td
Removed:
################################################################################
diff --git a/llvm/include/llvm/ADT/STLExtras.h b/llvm/include/llvm/ADT/STLExtras.h
index 372907be8a11d..eb001346b6093 100644
--- a/llvm/include/llvm/ADT/STLExtras.h
+++ b/llvm/include/llvm/ADT/STLExtras.h
@@ -1688,6 +1688,13 @@ auto unique(Range &&R, Predicate P) {
return std::unique(adl_begin(R), adl_end(R), P);
}
+/// Wrapper function around std::equal to detect if pair-wise elements between
+/// two ranges are the same.
+template <typename L, typename R> bool equal(L &&LRange, R &&RRange) {
+ return std::equal(adl_begin(LRange), adl_end(LRange), adl_begin(RRange),
+ adl_end(RRange));
+}
+
/// Wrapper function around std::equal to detect if all elements
/// in a container are same.
template <typename R>
diff --git a/mlir/include/mlir/IR/OpBase.td b/mlir/include/mlir/IR/OpBase.td
index c457cab3fd40d..c3fb49035f8a4 100644
--- a/mlir/include/mlir/IR/OpBase.td
+++ b/mlir/include/mlir/IR/OpBase.td
@@ -2366,10 +2366,7 @@ class TypesMatchWith<string summary, string lhsArg, string rhsArg,
// ranged arguments.
class RangedTypesMatchWith<string summary, string lhsArg, string rhsArg,
string transform>
- : TypesMatchWith<summary, lhsArg, rhsArg, transform,
- "[](auto &&lhs, auto &&rhs) { "
- "return std::equal(lhs.begin(), lhs.end(), rhs.begin(), rhs.end());"
- " }">;
+ : TypesMatchWith<summary, lhsArg, rhsArg, transform, "llvm::equal">;
// Type Constraint operand `idx`'s Element type is `type`.
class TCopVTEtIs<int idx, Type type> : And<[
More information about the llvm-commits
mailing list