MLIR  20.0.0git
Utils.h
Go to the documentation of this file.
1 //===- Utils.h - Transform dialect utilities --------------------*- 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 #ifndef MLIR_DIALECT_TRANSFORMS_UTILS_UTILS_H
10 #define MLIR_DIALECT_TRANSFORMS_UTILS_UTILS_H
11 
13 #include "mlir/IR/Value.h"
14 #include "mlir/IR/ValueRange.h"
15 #include "mlir/Support/LLVM.h"
16 
17 namespace mlir {
18 class OpAsmPrinter;
19 
20 namespace transform {
21 class TransformState;
22 
23 /// Printer hook for custom directive in assemblyFormat.
24 ///
25 /// custom<PackedOrDynamicIndexList>($packed, type($packed), $values,
26 /// type($values), $integers)
27 ///
28 /// where `values` are variadic Index values, `integers` is an `I64ArrayAttr`
29 /// and `packed` is a single transform dialect handle who's mapped payload ops
30 /// have a single Index result and represent the index list. Either `packed`
31 /// or the other two parameters may be specified.
32 ///
33 /// This allows idiomatic printing of mixed value and integer attributes in a
34 /// list or with a single handle. E.g., `[%arg0 : !transform.any_op, 7, 42,
35 /// %arg42 : !transform.param<i64>]` or just `%h : !transform.any_op`.
36 void printPackedOrDynamicIndexList(OpAsmPrinter &printer, Operation *op,
37  Value packed, Type packedType,
38  OperandRange values, TypeRange valueTypes,
39  DenseI64ArrayAttr integers);
41  Value packed, OperandRange values,
42  DenseI64ArrayAttr integers) {
43  printPackedOrDynamicIndexList(printer, op, packed, Type(), values,
44  TypeRange{}, integers);
45 }
46 
47 /// Parser hook for custom directive in assemblyFormat.
48 ///
49 /// custom<PackedOrDynamicIndexList>($packed, type($packed), $values,
50 /// type($values), $integers)
51 ///
52 /// See `printPackedOrDynamicIndexList` for details.
54  OpAsmParser &parser, std::optional<OpAsmParser::UnresolvedOperand> &packed,
56  SmallVectorImpl<Type> *valueTypes, DenseI64ArrayAttr &integers);
57 inline ParseResult parsePackedOrDynamicIndexList(
58  OpAsmParser &parser, std::optional<OpAsmParser::UnresolvedOperand> &packed,
60  DenseI64ArrayAttr &integers) {
61  Type packedType;
62  return parsePackedOrDynamicIndexList(parser, packed, packedType, values,
63  nullptr, integers);
64 }
65 } // namespace transform
66 } // namespace mlir
67 
68 #endif // MLIR_DIALECT_TRANSFORMS_UTILS_UTILS_H
The OpAsmParser has methods for interacting with the asm parser: parsing things from it,...
This is a pure-virtual base class that exposes the asmprinter hooks necessary to implement a custom p...
This class implements the operand iterators for the Operation class.
Definition: ValueRange.h:42
Operation is the basic unit of execution within MLIR.
Definition: Operation.h:88
This class provides an abstraction over the various different ranges of value types.
Definition: TypeRange.h:36
Instances of the Type class are uniqued, have an immutable identifier and an optional mutable compone...
Definition: Types.h:74
This class represents an instance of an SSA value in the MLIR system, representing a computable value...
Definition: Value.h:96
Base class for DenseArrayAttr that is instantiated and specialized for each supported element type be...
ParseResult parsePackedOrDynamicIndexList(OpAsmParser &parser, std::optional< OpAsmParser::UnresolvedOperand > &packed, Type &packedType, SmallVectorImpl< OpAsmParser::UnresolvedOperand > &values, SmallVectorImpl< Type > *valueTypes, DenseI64ArrayAttr &integers)
Parser hook for custom directive in assemblyFormat.
Definition: Utils.cpp:33
void printPackedOrDynamicIndexList(OpAsmPrinter &printer, Operation *op, Value packed, Type packedType, OperandRange values, TypeRange valueTypes, DenseI64ArrayAttr integers)
Printer hook for custom directive in assemblyFormat.
Definition: Utils.cpp:17
Include the generated interface declarations.
detail::DenseArrayAttrImpl< int64_t > DenseI64ArrayAttr