MLIR  20.0.0git
CallInterfaces.cpp
Go to the documentation of this file.
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 
10 
11 using namespace mlir;
12 
13 //===----------------------------------------------------------------------===//
14 // CallOpInterface
15 //===----------------------------------------------------------------------===//
16 
17 Operation *
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 = callable.get<SymbolRefAttr>();
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"
Operation is the basic unit of execution within MLIR.
Definition: Operation.h:88
This class represents a collection of SymbolTables.
Definition: SymbolTable.h:283
Operation * lookupNearestSymbolFrom(Operation *from, StringAttr symbol)
Returns the operation registered with the given symbol name within the closest parent operation of,...
static Operation * lookupNearestSymbolFrom(Operation *from, StringAttr symbol)
Returns the operation registered with the given symbol name within the closest parent operation of,...
Operation * resolveCallable(CallOpInterface call, SymbolTableCollection *symbolTable=nullptr)
Resolve the callable operation for given callee to a CallableOpInterface, or nullptr if a valid calla...
Include the generated interface declarations.
A callable is either a symbol, or an SSA value, that is referenced by a call-like operation.