This is an archive of the discontinued LLVM Phabricator instance.

[MLIR] Fix genTypeInterfaceMethods() to work correctly with InferTypeOpInterface
ClosedPublic

Authored by jurahul on Dec 1 2020, 11:21 AM.

Details

Summary
  • Change InferTypeOpInterface::inferResultTypes to use fully qualified types matching the ones generated by genTypeInterfaceMethods, so the redundancy can be detected.
  • Move genTypeInterfaceMethods() before genOpInterfaceMethods() so that the inferResultTypes method generated by genTypeInterfaceMethods() takes precedence over the declaration that might be generated by genOpInterfaceMethods()
  • Modified an op in the test dialect to exercise this (the modified op would fail to generate valid C++ code due to duplicate inferResultTypes methods).

Diff Detail

Event Timeline

jurahul created this revision.Dec 1 2020, 11:21 AM
jurahul requested review of this revision.Dec 1 2020, 11:21 AM
jurahul added a comment.EditedDec 1 2020, 11:27 AM

The fix here is such that TableGen generated inferReturnTypes takes precedence over the one generated by the InferTypeOpInterface. Just tagging the Op with the trait is not sufficient since I assume we also want the generated inferReturnTypes. The other possible fix is to avoid generating the TableGen generated inferReturnTypes method when the Op is tagged with DeclareOpInterfaceMethods<InferTypeOpInterface> and delegate the definition of the method to the user. I've erred on the side of using the TableGen one.

jpienaar accepted this revision.Dec 1 2020, 11:48 AM

Could we also remove the hard coding in genTypeInterfaceMethods ? (not for this one)

This revision is now accepted and ready to land.Dec 1 2020, 11:48 AM

Could we also remove the hard coding in genTypeInterfaceMethods ? (not for this one)

I did think of that, may be as a follow on change.