MLIR 24.0.0git
Utils.cpp
Go to the documentation of this file.
1//===- Utils.cpp - Transform dialect utilities ----------------------------===//
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
10
13
14using namespace mlir;
15using namespace mlir::transform;
16
18 OpAsmPrinter &printer, Operation *op, Value packed, Type packedType,
19 OperandRange values, TypeRange valueTypes, DenseBoolArrayAttr scalableFlags,
20 DenseI64ArrayAttr integers) {
21 if (packed) {
22 assert(values.empty() && (!integers || integers.empty()) &&
23 (!scalableFlags || scalableFlags.empty()) &&
24 "expected no values/integers");
25 printer << "*(" << packed;
26 if (packedType) {
27 printer << " : " << packedType;
28 }
29 printer << ")";
30 return;
31 }
32 printDynamicIndexList(printer, op, values, integers,
33 scalableFlags ? scalableFlags.asArrayRef()
35 valueTypes);
36}
37
39 OpAsmParser &parser, std::optional<OpAsmParser::UnresolvedOperand> &packed,
41 DenseBoolArrayAttr &scalableFlags, SmallVectorImpl<Type> *valueTypes,
42 DenseI64ArrayAttr &integers) {
44 if (parser.parseOptionalStar().succeeded()) {
45 if (parser.parseLParen().failed() ||
46 parser.parseOperand(packedOperand).failed())
47 return failure();
48 if (packedType && (parser.parseColonType(packedType).failed()))
49 return failure();
50 if (parser.parseRParen().failed())
51 return failure();
52 packed.emplace(packedOperand);
53 integers = parser.getBuilder().getDenseI64ArrayAttr({});
54 scalableFlags = parser.getBuilder().getDenseBoolArrayAttr({});
55 return success();
56 }
57
58 return parseDynamicIndexList(parser, values, integers, scalableFlags,
59 valueTypes);
60}
return success()
virtual Builder & getBuilder() const =0
Return a builder which provides useful access to MLIRContext, global objects like types and attribute...
virtual ParseResult parseRParen()=0
Parse a ) token.
virtual ParseResult parseColonType(Type &result)=0
Parse a colon followed by a type.
virtual ParseResult parseOptionalStar()=0
Parse a '*' token if present.
virtual ParseResult parseLParen()=0
Parse a ( token.
DenseI64ArrayAttr getDenseI64ArrayAttr(ArrayRef< int64_t > values)
Definition Builders.cpp:175
DenseBoolArrayAttr getDenseBoolArrayAttr(ArrayRef< bool > values)
Tensor-typed DenseArrayAttr getters.
Definition Builders.cpp:159
The OpAsmParser has methods for interacting with the asm parser: parsing things from it,...
virtual ParseResult parseOperand(UnresolvedOperand &result, bool allowResultNumber=true)=0
Parse a single SSA value operand name along with a result number if allowResultNumber is true.
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:44
Operation is the basic unit of execution within MLIR.
Definition Operation.h:87
This class provides an abstraction over the various different ranges of value types.
Definition TypeRange.h:40
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
ParseResult parsePackedOrDynamicIndexList(OpAsmParser &parser, std::optional< OpAsmParser::UnresolvedOperand > &packed, Type &packedType, SmallVectorImpl< OpAsmParser::UnresolvedOperand > &values, DenseBoolArrayAttr &scalableFlags, SmallVectorImpl< Type > *valueTypes, DenseI64ArrayAttr &integers)
Parser hook for custom directive in assemblyFormat.
Definition Utils.cpp:38
void printPackedOrDynamicIndexList(OpAsmPrinter &printer, Operation *op, Value packed, Type packedType, OperandRange values, TypeRange valueTypes, DenseBoolArrayAttr scalableFlags, DenseI64ArrayAttr integers)
Printer hook for custom directive in assemblyFormat.
Definition Utils.cpp:17
Include the generated interface declarations.
detail::DenseArrayAttrImpl< int64_t > DenseI64ArrayAttr
ParseResult parseDynamicIndexList(OpAsmParser &parser, SmallVectorImpl< OpAsmParser::UnresolvedOperand > &values, DenseI64ArrayAttr &integers, DenseBoolArrayAttr &scalableFlags, SmallVectorImpl< Type > *valueTypes=nullptr, AsmParser::Delimiter delimiter=AsmParser::Delimiter::Square)
Parser hooks for custom directive in assemblyFormat.
detail::DenseArrayAttrImpl< bool > DenseBoolArrayAttr
void printDynamicIndexList(OpAsmPrinter &printer, Operation *op, OperandRange values, ArrayRef< int64_t > integers, ArrayRef< bool > scalableFlags, TypeRange valueTypes=TypeRange(), AsmParser::Delimiter delimiter=AsmParser::Delimiter::Square)
Printer hooks for custom directive in assemblyFormat.
This is the representation of an operand reference.