1 //===- CallInterfaces.cpp - ControlFlow Interfaces ------------------------===// 2 // 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 6 // 7 //===----------------------------------------------------------------------===// 8 9 #include "mlir/Interfaces/CallInterfaces.h" 10 11 using namespace mlir; 12 13 //===----------------------------------------------------------------------===// 14 // CallOpInterface 15 //===----------------------------------------------------------------------===// 16 17 Operation * 18 call_interface_impl::resolveCallable(CallOpInterface call, 19 SymbolTableCollection *symbolTable) { 20 CallInterfaceCallable callable = call.getCallableForCallee(); 21 if (auto symbolVal = dyn_cast<Value>(callable)) 22 return symbolVal.getDefiningOp(); 23 24 // If the callable isn't a value, lookup the symbol reference. 25 auto symbolRef = cast<SymbolRefAttr>(callable); 26 if (symbolTable) 27 return symbolTable->lookupNearestSymbolFrom(call.getOperation(), symbolRef); 28 return SymbolTable::lookupNearestSymbolFrom(call.getOperation(), symbolRef); 29 } 30 31 //===----------------------------------------------------------------------===// 32 // CallInterfaces 33 //===----------------------------------------------------------------------===// 34 35 #include "mlir/Interfaces/CallInterfaces.cpp.inc" 36