| //===- InferTypeOpInterface.td - Infer Type interfaces -*- tablegen -----*-===// |
| // |
| // Copyright 2019 The MLIR Authors. |
| // |
| // Licensed under the Apache License, Version 2.0 (the "License"); |
| // you may not use this file except in compliance with the License. |
| // You may obtain a copy of the License at |
| // |
| // http://www.apache.org/licenses/LICENSE-2.0 |
| // |
| // Unless required by applicable law or agreed to in writing, software |
| // distributed under the License is distributed on an "AS IS" BASIS, |
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| // See the License for the specific language governing permissions and |
| // limitations under the License. |
| // ============================================================================= |
| // |
| // This file contains a set of interfaces that can be used to define information |
| // related to call-like and callable operations. Each of which are defined along |
| // with the respective interface below. |
| // |
| //===----------------------------------------------------------------------===// |
| |
| #ifdef MLIR_INFERTYPEOPINTERFACE |
| #else |
| #define MLIR_INFERTYPEOPINTERFACE |
| |
| #ifdef OP_BASE |
| #else |
| include "mlir/IR/OpBase.td" |
| #endif // OP_BASE |
| |
| // OpInterface to compute the return type of an operation. The arguments match |
| // those in Operation::create with the exception that the location is optional |
| // (if no location is provided, then the method will not emit an error on |
| // mismatch). |
| def InferTypeOpInterface : OpInterface<"InferTypeOpInterface"> { |
| let description = [{ |
| Interface to access a registered method to infer the return types for an |
| operation that could be used during op construction, verification or |
| type inference. |
| }]; |
| |
| let methods = [ |
| InterfaceMethod< |
| /*desc=*/[{Returns the return types that an op would generate. |
| |
| The method takes an optional location which, if set, will be used to |
| report errors on. The operands and attributes correspond to those with |
| which an Operation would be created (e.g., as used in Operation;:create). |
| Regions are the nested regions of the op. |
| }], |
| /*retTy=*/"SmallVector<Type, 2>", |
| /*methodName=*/"inferReturnTypes", |
| /*args=*/(ins "llvm::Optional<Location>":$location, |
| "ArrayRef<Value*>":$operands, |
| "ArrayRef<NamedAttribute>":$attributes, |
| "ArrayRef<Region>":$regions) |
| >, |
| ]; |
| } |
| |
| #endif // MLIR_INFERTYPEOPINTERFACE |