[clang][modules] Don't prevent translation of FW_Private includes when explicitly...
[llvm-project.git] / mlir / lib / Interfaces / CallInterfaces.cpp
blob455684d8e2ea7c418ad901bd09bd118d32d79a36
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 //===----------------------------------------------------------------------===//
9 #include "mlir/Interfaces/CallInterfaces.h"
11 using namespace mlir;
13 //===----------------------------------------------------------------------===//
14 // CallOpInterface
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.
21 Operation *
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>();
29 if (symbolTable)
30 return symbolTable->lookupNearestSymbolFrom(getOperation(), symbolRef);
31 return SymbolTable::lookupNearestSymbolFrom(getOperation(), symbolRef);
34 //===----------------------------------------------------------------------===//
35 // CallInterfaces
36 //===----------------------------------------------------------------------===//
38 #include "mlir/Interfaces/CallInterfaces.cpp.inc"