1//===- ParallelCombiningOpInterface.td - Parallel iface ----*- tablegen -*-===//
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// Defines the interface for ops that perform parallel combining operations.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef MLIR_INTERFACES_PARALLELCOMBININGOPINTERFACE
14#define MLIR_INTERFACES_PARALLELCOMBININGOPINTERFACE
15
16include "mlir/IR/OpBase.td"
17
18def ParallelCombiningOpInterface : OpInterface<"ParallelCombiningOpInterface"> {
19  let description = [{
20    A parallel combining op is an op with a region, that is not isolated from
21    above and yields values to its parent op without itself returning an SSA
22    value. The yielded values are determined by subvalues produced by the ops
23    contained in the region (the `yieldingOps`) and combined in any unspecified
24    order to produce the values yielded to the parent op.
25
26    This is useful as a terminator to parallel operations that iterate over
27    some set and return tensors while avoiding tight coupling between the
28    iterating op, the combining op and the individual subtensor producing ops.
29  }];
30  let cppNamespace = "::mlir";
31
32  let methods = [
33    InterfaceMethod<
34      /*desc=*/[{
35        Return `idx`^th result of the parent operation.
36      }],
37      /*retTy=*/"::mlir::OpResult",
38      /*methodName=*/"getParentResult",
39      /*args=*/(ins "int64_t":$idx),
40      /*methodBody=*/[{
41        return $_op.getParentResult(idx);
42      }]
43    >,
44    InterfaceMethod<
45      /*desc=*/[{
46        Return the contained ops that yield subvalues that this op combines to
47        yield to its parent.
48      }],
49      /*retTy=*/"::llvm::iterator_range<Block::iterator>",
50      /*methodName=*/"getYieldingOps",
51      /*args=*/(ins),
52      /*methodBody=*/[{
53        return $_op.getYieldingOps();
54      }]
55    >,
56    InterfaceMethod<
57      /*desc=*/[{
58        Return the contained ops that yield subvalues that this op combines to
59        yield to its parent.
60      }],
61      /*retTy=*/"::llvm::SmallVector<::mlir::Type>",
62      /*methodName=*/"getYieldedTypes",
63      /*args=*/(ins),
64      /*methodBody=*/[{
65        return $_op.getYieldedTypes();
66      }]
67    >,
68  ];
69  // TODO: Single region single block interface on interfaces ?
70  let verify = [{
71    return verifyParallelCombiningOpInterface($_op);
72  }];
73}
74
75#endif // MLIR_INTERFACES_PARALLELCOMBININGOPINTERFACE
76