xref: /llvm-project/mlir/include/mlir/Interfaces/ShapedOpInterfaces.td (revision 598f5275c16049b1e1b5bc934cbde447a82d485e)
1//===-- ShapedOpInterfaces.td - Interfaces for Shaped Ops --*- 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// This file contains a set of interfaces for ops that operate on shaped values.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef MLIR_INTERFACES_SHAPEDOPINTERFACES
14#define MLIR_INTERFACES_SHAPEDOPINTERFACES
15
16include "mlir/IR/OpBase.td"
17
18//===----------------------------------------------------------------------===//
19// ShapedDimOpInterface
20//===----------------------------------------------------------------------===//
21
22// Ops that return the dimension of a shaped value.
23def ShapedDimOpInterface : OpInterface<"ShapedDimOpInterface"> {
24  let description = [{
25    An interface for ops that return the dimension of a shaped value (such as a
26    tensor or a memref).  It provides access to the source shaped value and to
27    the dimension.
28  }];
29  let cppNamespace = "::mlir";
30
31  let methods = [
32    InterfaceMethod<
33      /*desc=*/[{
34        Return the shaped value operand. This is the value that the dimension
35        is taken from.
36      }],
37      /*retTy=*/"::mlir::Value",
38      /*methodName=*/"getShapedValue",
39      /*args=*/(ins)
40    >,
41    InterfaceMethod<
42      /*desc=*/[{
43        Return the dimension operand. This can be a constant or an SSA value.
44      }],
45      /*retTy=*/"::mlir::OpFoldResult",
46      /*methodName=*/"getDimension",
47      /*args=*/(ins)
48    >
49  ];
50
51  let verify = [{
52    return verifyShapedDimOpInterface($_op);
53  }];
54}
55
56#endif // MLIR_INTERFACES_SHAPEDOPINTERFACES
57