1 //===- CallInterfaces.h - Call Interfaces for MLIR --------------*- C++ -*-===// 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 // This file contains the definitions of the call interfaces defined in 10 // `CallInterfaces.td`. 11 // 12 //===----------------------------------------------------------------------===// 13 14 #ifndef MLIR_INTERFACES_CALLINTERFACES_H 15 #define MLIR_INTERFACES_CALLINTERFACES_H 16 17 #include "mlir/IR/SymbolTable.h" 18 #include "llvm/ADT/PointerUnion.h" 19 20 namespace mlir { 21 /// A callable is either a symbol, or an SSA value, that is referenced by a 22 /// call-like operation. This represents the destination of the call. 23 struct CallInterfaceCallable : public PointerUnion<SymbolRefAttr, Value> { 24 using PointerUnion<SymbolRefAttr, Value>::PointerUnion; 25 }; 26 27 class CallOpInterface; 28 29 namespace call_interface_impl { 30 31 /// Resolve the callable operation for given callee to a CallableOpInterface, or 32 /// nullptr if a valid callable was not resolved. `symbolTable` is an optional 33 /// parameter that will allow for using a cached symbol table for symbol lookups 34 /// instead of performing an O(N) scan. 35 Operation *resolveCallable(CallOpInterface call, 36 SymbolTableCollection *symbolTable = nullptr); 37 38 } // namespace call_interface_impl 39 40 } // namespace mlir 41 42 namespace llvm { 43 44 // Allow llvm::cast style functions. 45 template <typename To> 46 struct CastInfo<To, mlir::CallInterfaceCallable> 47 : public CastInfo<To, mlir::CallInterfaceCallable::PointerUnion> {}; 48 49 template <typename To> 50 struct CastInfo<To, const mlir::CallInterfaceCallable> 51 : public CastInfo<To, const mlir::CallInterfaceCallable::PointerUnion> {}; 52 53 } // namespace llvm 54 55 /// Include the generated interface declarations. 56 #include "mlir/Interfaces/CallInterfaces.h.inc" 57 58 #endif // MLIR_INTERFACES_CALLINTERFACES_H 59