MLIR 22.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, DenseI64ArrayAttr integers) {
20 if (packed) {
21 assert(values.empty() && (!integers || integers.empty()) &&
22 "expected no values/integers");
23 printer << "*(" << packed;
24 if (packedType) {
25 printer << " : " << packedType;
26 }
27 printer << ")";
28 return;
29 }
30 printDynamicIndexList(printer, op, values, integers, valueTypes);
31}
32
34 OpAsmParser &parser, std::optional<OpAsmParser::UnresolvedOperand> &packed,
36 SmallVectorImpl<Type> *valueTypes, DenseI64ArrayAttr &integers) {
38 if (parser.parseOptionalStar().succeeded()) {
39 if (parser.parseLParen().failed() ||
40 parser.parseOperand(packedOperand).failed())
41 return failure();
42 if (packedType && (parser.parseColonType(packedType).failed()))
43 return failure();
44 if (parser.parseRParen().failed())
45 return failure();
46 packed.emplace(packedOperand);
47 integers = parser.getBuilder().getDenseI64ArrayAttr({});
48 return success();
49 }
50
51 return parseDynamicIndexList(parser, values, integers, valueTypes);
52}
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:167
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:43
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:37
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, 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
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.
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.