[mlir] Update CallInterfaceCallable to use the new casting infra.

This enables casting LLVM style for mlir::CallInterfaceCallable usage.

Differential Revision: https://reviews.llvm.org/D135823
This commit is contained in:
Nick Kreeger 2022-10-13 20:33:24 -05:00
parent 0d253bbd33
commit e750c41ec1
3 changed files with 10 additions and 2 deletions

View File

@ -28,4 +28,12 @@ struct CallInterfaceCallable : public PointerUnion<SymbolRefAttr, Value> {
/// Include the generated interface declarations.
#include "mlir/Interfaces/CallInterfaces.h.inc"
namespace llvm {
template <typename To>
struct CastInfo<To, mlir::CallInterfaceCallable>
: public CastInfo<To, mlir::CallInterfaceCallable::PointerUnion> {};
} // namespace llvm
#endif // MLIR_INTERFACES_CALLINTERFACES_H

View File

@ -21,7 +21,7 @@ using namespace mlir;
Operation *
CallOpInterface::resolveCallable(SymbolTableCollection *symbolTable) {
CallInterfaceCallable callable = getCallableForCallee();
if (auto symbolVal = callable.dyn_cast<Value>())
if (auto symbolVal = dyn_cast<Value>(callable))
return symbolVal.getDefiningOp();
// If the callable isn't a value, lookup the symbol reference.

View File

@ -344,7 +344,7 @@ static void collectCallOps(iterator_range<Region::iterator> blocks,
if (auto call = dyn_cast<CallOpInterface>(op)) {
// TODO: Support inlining nested call references.
CallInterfaceCallable callable = call.getCallableForCallee();
if (SymbolRefAttr symRef = callable.dyn_cast<SymbolRefAttr>()) {
if (SymbolRefAttr symRef = dyn_cast<SymbolRefAttr>(callable)) {
if (!symRef.isa<FlatSymbolRefAttr>())
continue;
}