11 #include "llvm/Support/InterleavedRange.h"
50 [&]() {
return parser.
parseInteger(values.emplace_back()); });
51 if (listResult.failed())
65 UnitAttr isInverted, UnitAttr isAll) {
73 printer << llvm::interleaved(rawDimList.
asArrayRef());
81 bool inverted,
bool all) {
85 <<
"cannot request both 'all' and 'inverted' values in the list";
89 <<
"cannot both request 'all' and specific values in the list";
92 if (!all && raw.empty()) {
93 return op->
emitOpError() <<
"must request specific values in the list if "
94 "'all' is not specified";
97 auto *it = llvm::unique(rawVector);
98 if (it != rawVector.end())
99 return op->
emitOpError() <<
"expected the listed values to be unique";
107 assert(maxNumber > 0 &&
"expected size to be positive");
108 assert(!(isAll && isInverted) &&
"cannot invert all");
110 result = llvm::to_vector(llvm::seq<int64_t>(0, maxNumber));
115 llvm::SmallDenseSet<int64_t> visited;
116 expanded.reserve(rawList.size());
118 for (int64_t raw : rawList) {
119 int64_t updated = raw < 0 ? maxNumber + raw : raw;
120 if (updated >= maxNumber) {
122 <<
"position overflow " << updated <<
" (updated from " << raw
123 <<
") for maximum " << maxNumber;
127 <<
" (updated from " << raw <<
")";
129 if (!visited.insert(updated).second) {
131 <<
" (updated from " << raw <<
")";
133 target.push_back(updated);
139 result.reserve(result.size() + (maxNumber - expanded.size()));
140 for (int64_t candidate : llvm::seq<int64_t>(0, maxNumber)) {
141 if (llvm::is_contained(expanded, candidate))
143 result.push_back(candidate);
153 #include "mlir/Dialect/Transform/Interfaces/MatchInterfaces.cpp.inc"
constexpr static const llvm::StringLiteral kDimAllKeyword
Keyword syntax for full inclusion in positional specification.
constexpr static const llvm::StringLiteral kDimExceptKeyword
Keyword syntax for positional specification inversion.
virtual ParseResult parseCommaSeparatedList(Delimiter delimiter, function_ref< ParseResult()> parseElementFn, StringRef contextMessage=StringRef())=0
Parse a list of comma-separated items with an optional delimiter.
virtual Builder & getBuilder() const =0
Return a builder which provides useful access to MLIRContext, global objects like types and attribute...
virtual ParseResult parseOptionalKeyword(StringRef keyword)=0
Parse the given keyword if present.
virtual ParseResult parseRParen()=0
Parse a ) token.
ParseResult parseInteger(IntT &result)
Parse an integer value from the stream.
virtual ParseResult parseLParen()=0
Parse a ( token.
This class is a general helper class for creating context-global objects like types,...
DenseI64ArrayAttr getDenseI64ArrayAttr(ArrayRef< int64_t > values)
The result of a transform IR operation application.
static DiagnosedSilenceableFailure success()
Constructs a DiagnosedSilenceableFailure in the success state.
This class defines the main interface for locations in MLIR and acts as a non-nullable wrapper around...
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...
Operation is the basic unit of execution within MLIR.
InFlightDiagnostic emitOpError(const Twine &message={})
Emit an error with the op name prefixed, like "'dim' op " which is convenient for verifiers.
Base class for DenseArrayAttr that is instantiated and specialized for each supported element type be...
ArrayRef< T > asArrayRef() const
Include the generated interface declarations.
DiagnosedSilenceableFailure emitSilenceableFailure(Location loc, const Twine &message={})
Emits a silenceable failure with the given message.