Files
clang-p2996/mlir/lib/Dialect/Transform/Utils/Utils.cpp
Andrzej Warzynski 726835cd51 [mlir] Update how scalable indices are printed
This patch makes sure that scalable indices (that would normally
represent scalable tile or vector sizes) are printed correctly, i.e.
with additional square brackets:
```
%1, %loop = transform.structured.tile %0 [2, 8, [4]]
```

This change complements https://reviews.llvm.org/D150944 and is a part
of a larger effort to enable scalable vectorisation in Linalg. See this
RFC for more context:
  * https://discourse.llvm.org/t/rfc-scalable-vectorisation-in-linalg/

Differential Revision: https://reviews.llvm.org/D151978
2023-06-02 16:47:56 +01:00

48 lines
1.8 KiB
C++

//===- Utils.cpp - Transform dialect utilities ----------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "mlir/Dialect/Transform/Utils/Utils.h"
#include "mlir/IR/OpDefinition.h"
#include "mlir/Interfaces/ViewLikeInterface.h"
using namespace mlir;
using namespace mlir::transform;
void mlir::transform::printPackedOrDynamicIndexList(
OpAsmPrinter &printer, Operation *op, Value packed, Type packedType,
OperandRange values, TypeRange valueTypes, ArrayRef<int64_t> integers) {
if (packed) {
assert(values.empty() && integers.empty() && "expected no values/integers");
printer << "*(" << packed << " : " << packedType << ")";
return;
}
printDynamicIndexList(printer, op, values, integers, valueTypes);
}
ParseResult mlir::transform::parsePackedOrDynamicIndexList(
OpAsmParser &parser, std::optional<OpAsmParser::UnresolvedOperand> &packed,
Type &packedType, SmallVectorImpl<OpAsmParser::UnresolvedOperand> &values,
SmallVectorImpl<Type> &valueTypes, DenseI64ArrayAttr &integers) {
OpAsmParser::UnresolvedOperand packedOperand;
if (parser.parseOptionalStar().succeeded()) {
if (parser.parseLParen().failed() ||
parser.parseOperand(packedOperand).failed() ||
parser.parseColonType(packedType).failed() ||
parser.parseRParen().failed()) {
return failure();
}
packed.emplace(packedOperand);
integers = parser.getBuilder().getDenseI64ArrayAttr({});
return success();
}
return parseDynamicIndexList(parser, values, integers,
/*isTrailingIdxScalable=*/nullptr, &valueTypes);
}