1 //===- CallInterfaces.cpp - ControlFlow Interfaces ------------------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 #include "mlir/Interfaces/CallInterfaces.h"
13 //===----------------------------------------------------------------------===//
15 //===----------------------------------------------------------------------===//
17 /// Resolve the callable operation for given callee to a CallableOpInterface, or
18 /// nullptr if a valid callable was not resolved. `symbolTable` is an optional
19 /// parameter that will allow for using a cached symbol table for symbol lookups
20 /// instead of performing an O(N) scan.
22 CallOpInterface::resolveCallable(SymbolTableCollection
*symbolTable
) {
23 CallInterfaceCallable callable
= getCallableForCallee();
24 if (auto symbolVal
= dyn_cast
<Value
>(callable
))
25 return symbolVal
.getDefiningOp();
27 // If the callable isn't a value, lookup the symbol reference.
28 auto symbolRef
= callable
.get
<SymbolRefAttr
>();
30 return symbolTable
->lookupNearestSymbolFrom(getOperation(), symbolRef
);
31 return SymbolTable::lookupNearestSymbolFrom(getOperation(), symbolRef
);
34 //===----------------------------------------------------------------------===//
36 //===----------------------------------------------------------------------===//
38 #include "mlir/Interfaces/CallInterfaces.cpp.inc"