[llvm] [PatternMatching] Add generic API for matching constants using custom conditions (PR #85676)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 25 22:14:52 PDT 2024


================
@@ -460,6 +460,39 @@ template <typename Predicate> struct apf_pred_ty : public Predicate {
 //
 ///////////////////////////////////////////////////////////////////////////////
 
+template <typename APTy> struct custom_checkfn {
+  function_ref<bool(const APTy &)> CheckFn;
+  bool isValue(const APTy &C) { return CheckFn(C); }
+};
+
+// Match and integer or vector where CheckFn(ele) for each element is true.
+// For vectors, poison elements are assumed to match.
----------------
nikic wrote:

```suggestion
/// Match and integer or vector where CheckFn(ele) for each element is true.
/// For vectors, poison elements are assumed to match.
```

https://github.com/llvm/llvm-project/pull/85676


More information about the llvm-commits mailing list