Page MenuHomePhabricator

[mlir] Update DRR patterns to notify the rewriter why a pattern fails to match.
ClosedPublic

Authored by rriddle on Mar 17 2020, 6:01 PM.

Details

Summary

This adds support in RewriterGen for calling into the new PatternRewriter::notifyMatchFailure hook. This lets derived pattern rewriters display this information to users, an example from DialectConversion is shown below:

Legalizing operation : 'std.and'(0x60e0000066a0) {
  * Fold {
  } -> FAILURE : unable to fold

  * Pattern : 'std.and -> (spv.BitwiseAnd)' {
    ** Failure : operand 0 of op 'std.and' failed to satisfy constraint: '8/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4'
  } -> FAILURE : pattern failed to match

  * Pattern : 'std.and -> (spv.LogicalAnd)' {
    ** Failure : operand 0 of op 'std.and' failed to satisfy constraint: 'bool or vector of bool values of length 2/3/4'
  } -> FAILURE : pattern failed to match
} -> FAILURE : no matched legalization pattern

Depends On D76313

Diff Detail

Event Timeline

rriddle created this revision.Mar 17 2020, 6:01 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 17 2020, 6:01 PM
rriddle updated this revision to Diff 250959.Mar 17 2020, 6:46 PM

Remove unnecessary .data()

jpienaar accepted this revision.Mar 17 2020, 6:53 PM

Conciser than expected, thanks!

mlir/tools/mlir-tblgen/RewriterGen.cpp
86

match failure?

395

Missing space between h and (

422

Could you extract depth=0 as variable and use it here and in line 409?

This revision is now accepted and ready to land.Mar 17 2020, 6:53 PM
Harbormaster completed remote builds in B49527: Diff 250957.
rriddle updated this revision to Diff 250977.Mar 17 2020, 8:08 PM
rriddle marked 3 inline comments as done.

Resolve comments

This revision was automatically updated to reflect the committed changes.