# \[PSA\] Deprecating \`match\` and \`rewrite\`

**URL:** <https://discourse.llvm.org/t/psa-deprecating-match-and-rewrite/85048>\
**Category:** Deprecation & Important Refactoring\
**Created:** [March 8, 2025, 10:03am UTC](https://discourse.llvm.org/t/psa-deprecating-match-and-rewrite/85048 "2025-03-08T10:03:16Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![matthias-springer](https://sea1.discourse-cdn.com/flex021/user_avatar/discourse.llvm.org/matthias-springer/32/19066_2.png) [@matthias-springer](https://discourse.llvm.org/u/matthias-springer)\
**Post date:** [March 8, 2025, 10:03am UTC](https://discourse.llvm.org/t/psa-deprecating-match-and-rewrite/85048/1 "2025-03-08T10:03:16Z")

</div>

For historic reasons, `RewritePattern` and `ConversionPattern` have `match` and `rewrite` functions. With [[mlir][IR] Deprecate `match` and `rewrite` functions by matthias-springer · Pull Request #130031 · llvm/llvm-project · GitHub](https://github.com/llvm/llvm-project/pull/130031), these functions were deprecated in favor of `matchAndRewrite`. They will be removed [soon](https://github.com/llvm/llvm-project/pull/130259).

Please update your code base to use `matchAndRewrite` (e.g., by overriding `matchAndRewrite` with an implementation that simply calls `match` and `rewrite`).

---

<div class="post-metadata">

**Author:** ![kuhar](https://sea1.discourse-cdn.com/flex021/user_avatar/discourse.llvm.org/kuhar/32/573_2.png) [@kuhar](https://discourse.llvm.org/u/kuhar)\
**Post date:** [March 9, 2025, 1:01am UTC](https://discourse.llvm.org/t/psa-deprecating-match-and-rewrite/85048/2 "2025-03-09T01:01:58Z")

</div>

Should we also add it to: [Deprecations & Current Refactoring - MLIR](https://mlir.llvm.org/deprecation/) ?

---

<div class="post-metadata">

**Author:** ![matthias-springer](https://sea1.discourse-cdn.com/flex021/user_avatar/discourse.llvm.org/matthias-springer/32/19066_2.png) [@matthias-springer](https://discourse.llvm.org/u/matthias-springer)\
**Post date:** [March 9, 2025, 5:29pm UTC](https://discourse.llvm.org/t/psa-deprecating-match-and-rewrite/85048/3 "2025-03-09T17:29:30Z")

</div>

I uploaded a PR: [Add deprecation notice for `match` and `rewrite` by matthias-springer · Pull Request #217 · llvm/mlir-www · GitHub](https://github.com/llvm/mlir-www/pull/217)

I cannot add any reviewers though.

---

<div class="post-metadata">

**Author:** ![jpienaar](https://sea1.discourse-cdn.com/flex021/user_avatar/discourse.llvm.org/jpienaar/32/225_2.png) [@jpienaar](https://discourse.llvm.org/u/jpienaar)\
**Post date:** [March 10, 2025, 3:45pm UTC](https://discourse.llvm.org/t/psa-deprecating-match-and-rewrite/85048/4 "2025-03-10T15:45:43Z")

</div>

Submitted. Thanks for the headsup.

---

<div class="post-metadata">

**Author:** ![banach-space](https://sea1.discourse-cdn.com/flex021/user_avatar/discourse.llvm.org/banach-space/32/209_2.png) [@banach-space](https://discourse.llvm.org/u/banach-space)\
**Post date:** [March 10, 2025, 5:10pm UTC](https://discourse.llvm.org/t/psa-deprecating-match-and-rewrite/85048/5 "2025-03-10T17:10:37Z")

</div>

The end of an era 🙂

Thanks @matthias-springer , fantastic community work, much appreciated!

-Andrzej

---

<div class="post-metadata">

**Author:** ![JueonPark](https://sea1.discourse-cdn.com/flex021/user_avatar/discourse.llvm.org/jueonpark/32/20402_2.png) [@JueonPark](https://discourse.llvm.org/u/JueonPark)\
**Post date:** [March 14, 2025, 8:28am UTC](https://discourse.llvm.org/t/psa-deprecating-match-and-rewrite/85048/6 "2025-03-14T08:28:07Z")

</div>

Hello, I have a question regarding this deprecation.  
Will functions such as `matchPattern` or `Pattern::match()` be deprecated as well?

---

<div class="post-metadata">

**Author:** ![matthias-springer](https://sea1.discourse-cdn.com/flex021/user_avatar/discourse.llvm.org/matthias-springer/32/19066_2.png) [@matthias-springer](https://discourse.llvm.org/u/matthias-springer)\
**Post date:** [March 14, 2025, 10:50am UTC](https://discourse.llvm.org/t/psa-deprecating-match-and-rewrite/85048/7 "2025-03-14T10:50:30Z")

</div>

No, IR matchers (API in `mlir/IR/Matchers.h`) will stay as is.

---

<div class="post-metadata">

**Author:** ![JueonPark](https://sea1.discourse-cdn.com/flex021/user_avatar/discourse.llvm.org/jueonpark/32/20402_2.png) [@JueonPark](https://discourse.llvm.org/u/JueonPark)\
**Post date:** [March 16, 2025, 2:19am UTC](https://discourse.llvm.org/t/psa-deprecating-match-and-rewrite/85048/8 "2025-03-16T02:19:31Z")

</div>

Thank you for the reply 🙂
