[PATCH] D48326: [RFC] "Alternative" matches for TableGen DAG patterns

Ulrich Weigand via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 20 08:18:05 PDT 2018


uweigand added a comment.

In https://reviews.llvm.org/D48326#1137723, @kparzysz wrote:

> For the purposes of matching the main pattern is really the same as the ones specified by `Pat`s.  I am opposed to making this feature specific to the "Pattern" field, (1) because this is a very useful feature to have in general, and (2) because if the implementation is main-pattern-specific, it would need to be replaced to make it work with Pats in the future. The main strength of this feature comes from multiple "source patterns" in a PatFrag.


Fully agreed, it certainly should work for any pattern matching, both main pattern and Pat.

> The main issue you'd encounter is that wherever there is a single pattern in CodeGenDAGPatterns.cpp, there will now have to be a list of them.  The function InlinePatternFragments would create new patterns for each alternative source pattern, so it would no longer be single input -> single output, but single input -> multiple outputs.  Other than that, there shouldn't really be more significant differences.  The patterns are detached from instruction definitions as soon as you add them to the PatternsToMatch list.

Sure, for adding to the PatternsToMatch list I can see how this would work.  What I was wondering is those **other** uses of the main pattern, e.g. to find implicit register definitions -- this is where the main pattern already today can be a list of multiple patterns, where all but the first one must be `implicit` statements.  If a PatFrag expands the first pattern in the list to multiple ones, how will those implicit statements then fit in?  There's also this bit in `MatcherGen::EmitResultInstructionAsOperand` where the main pattern is specifically consulted again to find out whether to place a chain on this output node ...  This can probably all be made to work somehow, it's just something that needs a bit more investigation ...

(In general, it seems that those other uses of the main pattern are a bit dubious anyway -- I'm seeing comments that the main pattern and a `Pat` statement really ought to be equivalent, but currently aren't ...)


Repository:
  rL LLVM

https://reviews.llvm.org/D48326





More information about the llvm-commits mailing list