It was originally placed in TransformInterfaces for convenience, but it is really a generic utility. It may also create an include cycle between TransformTypes and TransformInterfaces if the latter needs to include the former because the former uses the failure util. Reviewed By: springerm Differential Revision: https://reviews.llvm.org/D140978
40 lines
1.4 KiB
C++
40 lines
1.4 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, OperandRange values,
|
|
ArrayRef<int64_t> integers) {
|
|
if (packed) {
|
|
assert(values.empty() && integers.empty() && "expected no values/integers");
|
|
printer << packed;
|
|
return;
|
|
}
|
|
printDynamicIndexList(printer, op, values, integers);
|
|
}
|
|
|
|
ParseResult mlir::transform::parsePackedOrDynamicIndexList(
|
|
OpAsmParser &parser, std::optional<OpAsmParser::UnresolvedOperand> &packed,
|
|
SmallVectorImpl<OpAsmParser::UnresolvedOperand> &values,
|
|
DenseI64ArrayAttr &integers) {
|
|
OpAsmParser::UnresolvedOperand packedOperand;
|
|
if (parser.parseOptionalOperand(packedOperand).has_value()) {
|
|
packed.emplace(packedOperand);
|
|
integers = parser.getBuilder().getDenseI64ArrayAttr({});
|
|
return success();
|
|
}
|
|
return parseDynamicIndexList(parser, values, integers);
|
|
}
|