[llvm] [GlobalISel][TableGen] MIR Pattern Variadics (PR #100563)

Pierre van Houtryve via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 29 00:13:01 PDT 2024


Pierre-vh wrote:

> `G_MUL $x, GIVariadic<>:$lhsAndRhs`should give an error. G_MUL is not variadic. It is a misuse of the feature.

I'm really not convinced this count as a misuse, but I also struggle to imagine a use case where GIVariadic could be used outside a variadic instruction. I was thinking having templated pattern where the instructions have different number of opcodes but it's kind 
of a stretch. I'll think about it a bit more.

> defs will probably need a different syntax.

For defs we could just have things like `G_UNMERGE_VALUES GIVariadic<>:$defs, $aggregate`.
The complexity isn't in the syntax but in how the resulting pattern gets generated, because now we no longer know the index of `$aggregate` - it depends on the size of defs.
I would need a way to encode operands starting from the back, so maybe have reverse indexes (e.g. -1 is last operand). Or a way to index the defs and use separately (perhaps with some opcodes changing the indexing mode). Any solution implies a lot of change to pattern codegen so that's part of the reason why I don't want to tackle this now (this patch is already pretty big as is)


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


More information about the llvm-commits mailing list