MLIR  17.0.0git
ViewLikeInterface.h
Go to the documentation of this file.
1 //===- ViewLikeInterface.h - View-like operations interface ---------------===//
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 implements the operation interface for view-like operations.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #ifndef MLIR_INTERFACES_VIEWLIKEINTERFACE_H_
14 #define MLIR_INTERFACES_VIEWLIKEINTERFACE_H_
15 
17 #include "mlir/IR/Builders.h"
19 #include "mlir/IR/BuiltinTypes.h"
21 
22 namespace mlir {
23 
24 class OffsetSizeAndStrideOpInterface;
25 
26 namespace detail {
27 
28 LogicalResult verifyOffsetSizeAndStrideOp(OffsetSizeAndStrideOpInterface op);
29 
31  OffsetSizeAndStrideOpInterface a, OffsetSizeAndStrideOpInterface b,
32  llvm::function_ref<bool(OpFoldResult, OpFoldResult)> cmp);
33 
34 } // namespace detail
35 } // namespace mlir
36 
37 /// Include the generated interface declarations.
38 #include "mlir/Interfaces/ViewLikeInterface.h.inc"
39 
40 namespace mlir {
41 
42 /// Printer hook for custom directive in assemblyFormat.
43 ///
44 /// custom<DynamicIndexList>($values, $integers)
45 ///
46 /// where `values` is of ODS type `Variadic<Index>` and `integers` is of ODS
47 /// type `I64ArrayAttr`. Prints a list with either (1) the static integer value
48 /// in `integers` is `dynVal` or (2) the next value otherwise. This allows
49 /// idiomatic printing of mixed value and integer attributes in a list. E.g.
50 /// `[%arg0, 7, 42, %arg42]`.
51 void printDynamicIndexList(OpAsmPrinter &printer, Operation *op,
52  OperandRange values, ArrayRef<int64_t> integers);
53 
54 /// Pasrer hook for custom directive in assemblyFormat.
55 ///
56 /// custom<DynamicIndexList>($values, $integers)
57 ///
58 /// where `values` is of ODS type `Variadic<Index>` and `integers` is of ODS
59 /// type `I64ArrayAttr`. Parse a mixed list with either (1) static integer
60 /// values or (2) SSA values. Fill `integers` with the integer ArrayAttr, where
61 /// `dynVal` encodes the position of SSA values. Add the parsed SSA values
62 /// to `values` in-order.
63 //
64 /// E.g. after parsing "[%arg0, 7, 42, %arg42]":
65 /// 1. `result` is filled with the i64 ArrayAttr "[`dynVal`, 7, 42, `dynVal`]"
66 /// 2. `ssa` is filled with "[%arg0, %arg1]".
67 ParseResult
68 parseDynamicIndexList(OpAsmParser &parser,
69  SmallVectorImpl<OpAsmParser::UnresolvedOperand> &values,
70  DenseI64ArrayAttr &integers);
71 
72 /// Verify that a the `values` has as many elements as the number of entries in
73 /// `attr` for which `isDynamic` evaluates to true.
74 LogicalResult verifyListOfOperandsOrIntegers(Operation *op, StringRef name,
75  unsigned expectedNumElements,
76  ArrayRef<int64_t> attr,
77  ValueRange values);
78 
79 } // namespace mlir
80 
81 #endif // MLIR_INTERFACES_VIEWLIKEINTERFACE_H_
bool sameOffsetsSizesAndStrides(OffsetSizeAndStrideOpInterface a, OffsetSizeAndStrideOpInterface b, llvm::function_ref< bool(OpFoldResult, OpFoldResult)> cmp)
LogicalResult verifyOffsetSizeAndStrideOp(OffsetSizeAndStrideOpInterface op)
Include the generated interface declarations.
void printDynamicIndexList(OpAsmPrinter &printer, Operation *op, OperandRange values, ArrayRef< int64_t > integers)
Printer hook for custom directive in assemblyFormat.
detail::DenseArrayAttrImpl< int64_t > DenseI64ArrayAttr
ParseResult parseDynamicIndexList(OpAsmParser &parser, SmallVectorImpl< OpAsmParser::UnresolvedOperand > &values, DenseI64ArrayAttr &integers)
Pasrer hook for custom directive in assemblyFormat.
LogicalResult verifyListOfOperandsOrIntegers(Operation *op, StringRef name, unsigned expectedNumElements, ArrayRef< int64_t > attr, ValueRange values)
Verify that a the values has as many elements as the number of entries in attr for which isDynamic ev...