This is an archive of the discontinued LLVM Phabricator instance.

[mlir] Move FunctionInterfaces to Interfaces directory and inherit from CallableOpInterface
ClosedPublic

Authored by maerhart on Aug 15 2023, 7:57 AM.

Details

Summary

Functions are always callable operations and thus every operation
implementing the FunctionOpInterface also implements the
CallableOpInterface. The only exception was the FuncOp in the toy
example. To make implementation of the FunctionOpInterface easier,
this commit lets FunctionOpInterface inherit from
CallableOpInterface and merges some of their methods. More precisely,
the CallableOpInterface has methods to get the argument and result
attributes and a method to get the result types of the callable region.
These methods are always implemented the same way as their analogues in
FunctionOpInterface and thus this commit moves all the argument and
result attribute handling methods to the callable interface as well as
the methods to get the argument and result types. The
FuntionOpInterface then does not have to declare them as well, but
just inherits them from the CallableOpInterface.
Adding the inheritance relation also required to move the
FunctionOpInterface from the IR directory to the Interfaces directory
since IR should not depend on Interfaces.

Diff Detail

Event Timeline

maerhart created this revision.Aug 15 2023, 7:57 AM
Herald added a reviewer: rriddle. · View Herald Transcript
Herald added a reviewer: jpienaar. · View Herald Transcript
Herald added a reviewer: ftynse. · View Herald Transcript
Herald added a reviewer: dcaballe. · View Herald Transcript
Herald added a reviewer: kuhar. · View Herald Transcript
Herald added a project: Restricted Project. · View Herald Transcript
maerhart requested review of this revision.Aug 15 2023, 7:57 AM
springerm accepted this revision.Aug 17 2023, 2:13 AM

This change makes sense to me! Lots of redundant code (duplicate interface methods on CallOpInterface and FunctionOpInterface) is deleted.

jpienaar accepted this revision.Aug 30 2023, 1:03 PM

Looks good, thanks!

This revision is now accepted and ready to land.Aug 30 2023, 1:03 PM
maerhart updated this revision to Diff 554930.Aug 31 2023, 1:14 AM

rebase to current main, fix a build issue

maerhart updated this revision to Diff 554949.Aug 31 2023, 2:40 AM

Make CMake and Bazel build target naming more consistent

This revision was landed with ongoing or failed builds.Aug 31 2023, 4:29 AM
This revision was automatically updated to reflect the committed changes.