[llvm] [GlobalIsel] Add Gallery to MIR Patterns (PR #89974)

Thorsten Schütt via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 24 11:48:35 PDT 2024


https://github.com/tschuett created https://github.com/llvm/llvm-project/pull/89974

None

>From ba56f97273a24e3ff2b6244bbf5badd892dbc2c5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Thorsten=20Sch=C3=BCtt?= <schuett at gmail.com>
Date: Wed, 24 Apr 2024 20:46:27 +0200
Subject: [PATCH] [GlobalIsel]  Add Gallery to MIr Patterns

---
 llvm/docs/GlobalISel/MIRPatterns.rst | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/llvm/docs/GlobalISel/MIRPatterns.rst b/llvm/docs/GlobalISel/MIRPatterns.rst
index 728e3247014452..97717005ebd619 100644
--- a/llvm/docs/GlobalISel/MIRPatterns.rst
+++ b/llvm/docs/GlobalISel/MIRPatterns.rst
@@ -514,3 +514,21 @@ of operands.
     (match (does_not_bind $tmp, $x)
            (G_MUL $dst, $x, $tmp)),
     (apply (COPY $dst, $x))>;
+
+
+ Gallery
+----------------
+
+We should use precise patterns that state our intentions. Please avoid
+using wip_match_opcode in patterns.
+
+.. code-block:: text
+  :caption: Example fold ext(trunc)
+
+(match (wip_match_opcode G_ZEXT):$root,
+
+(match (G_TRUNC $src, $x),
+       (G_ZEXT $root, $src),
+
+(match (G_TRUNC $src, $x, (MIFlags NoUWrap)),
+       (G_ZEXT $root, $src),



More information about the llvm-commits mailing list