[mlir][CallOpInterface] Add `setCalleeFromCallable` method
authorWhitney Tsang <whitney.tsang@intel.com>
Mon, 8 May 2023 13:07:10 +0000 (06:07 -0700)
committerWhitney Tsang <whitney.tsang@intel.com>
Mon, 8 May 2023 13:07:10 +0000 (06:07 -0700)
commita2ab6a5e2b8d4e10ce29b24db7d6ae18c9acbec1
tree7d6df7060808ad22aff07e369ff740a46875114e
parent9fca0313f8c34ca9b4b5c434d4d013e86f47537a
[mlir][CallOpInterface] Add `setCalleeFromCallable` method

Currently `CallOpInterface` has a method `getCallableForCallee` to have a consistent way to get the callee from an operation with `CallOpInterface`, but missing a consistent way to set a callee for an operation with `CallOpInterface`.

A set callee method is useful for transformations that operate on `CallOpInterface`, and change the callee, e.g., a pass that specialize function, which clone the callee, and change the `CallOpInterface`'s callee to the cloned version. Without such method, transformation would need to understand the implementation for every operations with `CallOpInterface`, and have a type switch to handle them.

This review adds a method to set callee for operation with `CallOpInterface`.

Reviewed By: gysit, zero9178o

Differential Revision: https://reviews.llvm.org/D149763
14 files changed:
flang/include/flang/Optimizer/Dialect/FIROps.td
mlir/docs/Interfaces.md
mlir/docs/Tutorials/Toy/Ch-4.md
mlir/examples/toy/Ch4/mlir/Dialect.cpp
mlir/examples/toy/Ch5/mlir/Dialect.cpp
mlir/examples/toy/Ch6/mlir/Dialect.cpp
mlir/examples/toy/Ch7/mlir/Dialect.cpp
mlir/include/mlir/Dialect/Async/IR/AsyncOps.td
mlir/include/mlir/Dialect/Func/IR/FuncOps.td
mlir/include/mlir/Dialect/Transform/IR/TransformOps.td
mlir/include/mlir/Interfaces/CallInterfaces.td
mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
mlir/lib/Dialect/SPIRV/IR/SPIRVOps.cpp
mlir/test/lib/Dialect/Test/TestOps.td