[PATCH] D159111: [TableGen][GlobalISel] Add support for matching/writing MIFlags in MIR Patterns

Pierre van Houtryve via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 29 23:28:30 PDT 2023


Pierre-vh marked 2 inline comments as done.
Pierre-vh added inline comments.


================
Comment at: llvm/docs/GlobalISel/MIRPatterns.rst:171
+mentionned multiple times, it's only checked/added once.
 
 Limitations
----------------
arsenm wrote:
> Should mention the default behavior. Flags should be dropped unless explicitly preserved. Can you and/or the incoming flags?
The current behavior is that the output instruction is a "blank canvas" so no flags are preserved, and no there's no way to fetch the flags from an instruction & preserve them (hence why I added the `PropagateFlags` bool).  

Is there any use case where we need to match only one flag and optionally preserve the other flags?

If the set of possibilities is relatively small, a PatFrag can do it - just explicitly match & rewrite them. Not ideal but it works. I'm sure it could all be written with some loop in TableGen as well.

Otherwise, maybe we could have a builtin for that, something like `GIMIFlagsAnd<$a, $b>` but we also need to be careful about `GIR_MutateOpcode` (which may erase the flags from the original inst), so it's not 100% trivial.



================
Comment at: llvm/include/llvm/CodeGen/GlobalISel/GIMatchTableExecutor.h:566
 protected:
-  GIMatchTableExecutor();
+  const bool PropagateMIFlags;
+
----------------
arsenm wrote:
> Don't see why this needs to be configurable
I was wondering what happens if a root has some MI flags, and the pattern rewrites the root & other instructions. Do we really have to propagate flags from the root inst in the combiner?

I have no strong opinion, it just seemed wrong to me so I disabled it for the combiner.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D159111/new/

https://reviews.llvm.org/D159111



More information about the llvm-commits mailing list