diff --git a/flang/lib/Optimizer/Dialect/FIRType.cpp b/flang/lib/Optimizer/Dialect/FIRType.cpp --- a/flang/lib/Optimizer/Dialect/FIRType.cpp +++ b/flang/lib/Optimizer/Dialect/FIRType.cpp @@ -286,7 +286,7 @@ //===----------------------------------------------------------------------===// // `boxproc` `<` return-type `>` -mlir::Type BoxProcType::parse(mlir::DialectAsmParser &parser) { +mlir::Type BoxProcType::parse(mlir::AsmParser &parser) { mlir::Type ty; if (parser.parseLess() || parser.parseType(ty) || parser.parseGreater()) return {}; @@ -319,7 +319,7 @@ //===----------------------------------------------------------------------===// // `box` `<` type (',' affine-map)? `>` -mlir::Type fir::BoxType::parse(mlir::DialectAsmParser &parser) { +mlir::Type fir::BoxType::parse(mlir::AsmParser &parser) { mlir::Type ofTy; if (parser.parseLess() || parser.parseType(ofTy)) return {}; @@ -355,7 +355,7 @@ // BoxCharType //===----------------------------------------------------------------------===// -mlir::Type fir::BoxCharType::parse(mlir::DialectAsmParser &parser) { +mlir::Type fir::BoxCharType::parse(mlir::AsmParser &parser) { return parseKindSingleton(parser); } @@ -377,7 +377,7 @@ //===----------------------------------------------------------------------===// // `char` `<` kind [`,` `len`] `>` -mlir::Type fir::CharacterType::parse(mlir::DialectAsmParser &parser) { +mlir::Type fir::CharacterType::parse(mlir::AsmParser &parser) { int kind = 0; if (parser.parseLess() || parser.parseInteger(kind)) return {}; @@ -411,7 +411,7 @@ // ComplexType //===----------------------------------------------------------------------===// -mlir::Type fir::ComplexType::parse(mlir::DialectAsmParser &parser) { +mlir::Type fir::ComplexType::parse(mlir::AsmParser &parser) { return parseKindSingleton(parser); } @@ -428,7 +428,7 @@ //===----------------------------------------------------------------------===// // `heap` `<` type `>` -mlir::Type fir::HeapType::parse(mlir::DialectAsmParser &parser) { +mlir::Type fir::HeapType::parse(mlir::AsmParser &parser) { return parseTypeSingleton(parser); } @@ -450,7 +450,7 @@ //===----------------------------------------------------------------------===// // `int` `<` kind `>` -mlir::Type fir::IntegerType::parse(mlir::DialectAsmParser &parser) { +mlir::Type fir::IntegerType::parse(mlir::AsmParser &parser) { return parseKindSingleton(parser); } @@ -463,7 +463,7 @@ //===----------------------------------------------------------------------===// // `logical` `<` kind `>` -mlir::Type fir::LogicalType::parse(mlir::DialectAsmParser &parser) { +mlir::Type fir::LogicalType::parse(mlir::AsmParser &parser) { return parseKindSingleton(parser); } @@ -476,7 +476,7 @@ //===----------------------------------------------------------------------===// // `ptr` `<` type `>` -mlir::Type fir::PointerType::parse(mlir::DialectAsmParser &parser) { +mlir::Type fir::PointerType::parse(mlir::AsmParser &parser) { return parseTypeSingleton(parser); } @@ -497,7 +497,7 @@ //===----------------------------------------------------------------------===// // `real` `<` kind `>` -mlir::Type fir::RealType::parse(mlir::DialectAsmParser &parser) { +mlir::Type fir::RealType::parse(mlir::AsmParser &parser) { return parseKindSingleton(parser); } @@ -520,7 +520,7 @@ // `type` `<` name // (`(` id `:` type (`,` id `:` type)* `)`)? // (`{` id `:` type (`,` id `:` type)* `}`)? '>' -mlir::Type fir::RecordType::parse(mlir::DialectAsmParser &parser) { +mlir::Type fir::RecordType::parse(mlir::AsmParser &parser) { llvm::StringRef name; if (parser.parseLess() || parser.parseKeyword(&name)) return {}; @@ -647,7 +647,7 @@ //===----------------------------------------------------------------------===// // `ref` `<` type `>` -mlir::Type fir::ReferenceType::parse(mlir::DialectAsmParser &parser) { +mlir::Type fir::ReferenceType::parse(mlir::AsmParser &parser) { return parseTypeSingleton(parser); } @@ -670,7 +670,7 @@ // `array` `<` `*` | bounds (`x` bounds)* `:` type (',' affine-map)? `>` // bounds ::= `?` | int-lit -mlir::Type fir::SequenceType::parse(mlir::DialectAsmParser &parser) { +mlir::Type fir::SequenceType::parse(mlir::AsmParser &parser) { if (parser.parseLess()) return {}; SequenceType::Shape shape; @@ -758,7 +758,7 @@ // ShapeType //===----------------------------------------------------------------------===// -mlir::Type fir::ShapeType::parse(mlir::DialectAsmParser &parser) { +mlir::Type fir::ShapeType::parse(mlir::AsmParser &parser) { return parseRankSingleton(parser); } @@ -770,7 +770,7 @@ // ShapeShiftType //===----------------------------------------------------------------------===// -mlir::Type fir::ShapeShiftType::parse(mlir::DialectAsmParser &parser) { +mlir::Type fir::ShapeShiftType::parse(mlir::AsmParser &parser) { return parseRankSingleton(parser); } @@ -782,7 +782,7 @@ // ShiftType //===----------------------------------------------------------------------===// -mlir::Type fir::ShiftType::parse(mlir::DialectAsmParser &parser) { +mlir::Type fir::ShiftType::parse(mlir::AsmParser &parser) { return parseRankSingleton(parser); } @@ -795,7 +795,7 @@ //===----------------------------------------------------------------------===// // `slice` `<` rank `>` -mlir::Type fir::SliceType::parse(mlir::DialectAsmParser &parser) { +mlir::Type fir::SliceType::parse(mlir::AsmParser &parser) { return parseRankSingleton(parser); } @@ -808,7 +808,7 @@ //===----------------------------------------------------------------------===// // `tdesc` `<` type `>` -mlir::Type fir::TypeDescType::parse(mlir::DialectAsmParser &parser) { +mlir::Type fir::TypeDescType::parse(mlir::AsmParser &parser) { return parseTypeSingleton(parser); } @@ -832,7 +832,7 @@ //===----------------------------------------------------------------------===// // `vector` `<` len `:` type `>` -mlir::Type fir::VectorType::parse(mlir::DialectAsmParser &parser) { +mlir::Type fir::VectorType::parse(mlir::AsmParser &parser) { int64_t len = 0; mlir::Type eleTy; if (parser.parseLess() || parser.parseInteger(len) || parser.parseColon() || diff --git a/mlir/include/mlir/Dialect/DLTI/DLTI.h b/mlir/include/mlir/Dialect/DLTI/DLTI.h --- a/mlir/include/mlir/Dialect/DLTI/DLTI.h +++ b/mlir/include/mlir/Dialect/DLTI/DLTI.h @@ -51,10 +51,10 @@ Attribute getValue() const; /// Parses an instance of this attribute. - static DataLayoutEntryAttr parse(DialectAsmParser &parser); + static DataLayoutEntryAttr parse(AsmParser &parser); /// Prints this attribute. - void print(DialectAsmPrinter &os) const; + void print(AsmPrinter &os) const; }; //===----------------------------------------------------------------------===// @@ -99,10 +99,10 @@ DataLayoutEntryListRef getEntries() const; /// Parses an instance of this attribute. - static DataLayoutSpecAttr parse(DialectAsmParser &parser); + static DataLayoutSpecAttr parse(AsmParser &parser); /// Prints this attribute. - void print(DialectAsmPrinter &os) const; + void print(AsmPrinter &os) const; }; } // namespace mlir diff --git a/mlir/include/mlir/Dialect/LLVMIR/LLVMTypes.h b/mlir/include/mlir/Dialect/LLVMIR/LLVMTypes.h --- a/mlir/include/mlir/Dialect/LLVMIR/LLVMTypes.h +++ b/mlir/include/mlir/Dialect/LLVMIR/LLVMTypes.h @@ -24,8 +24,8 @@ namespace mlir { -class DialectAsmParser; -class DialectAsmPrinter; +class AsmParser; +class AsmPrinter; namespace LLVM { class LLVMDialect; @@ -419,7 +419,7 @@ Type parseType(DialectAsmParser &parser); /// Prints an LLVM Dialect type. -void printType(Type type, DialectAsmPrinter &printer); +void printType(Type type, AsmPrinter &printer); } // namespace detail //===----------------------------------------------------------------------===// diff --git a/mlir/include/mlir/Dialect/Vector/VectorOps.h b/mlir/include/mlir/Dialect/Vector/VectorOps.h --- a/mlir/include/mlir/Dialect/Vector/VectorOps.h +++ b/mlir/include/mlir/Dialect/Vector/VectorOps.h @@ -101,8 +101,8 @@ CombiningKind getKind() const; - void print(DialectAsmPrinter &p) const; - static Attribute parse(DialectAsmParser &parser); + void print(AsmPrinter &p) const; + static Attribute parse(AsmParser &parser, Type type); }; /// Collects patterns to progressively lower vector.broadcast ops on high-D diff --git a/mlir/include/mlir/IR/DialectImplementation.h b/mlir/include/mlir/IR/DialectImplementation.h --- a/mlir/include/mlir/IR/DialectImplementation.h +++ b/mlir/include/mlir/IR/DialectImplementation.h @@ -62,7 +62,7 @@ struct FieldParser< AttributeT, std::enable_if_t::value, AttributeT>> { - static FailureOr parse(DialectAsmParser &parser) { + static FailureOr parse(AsmParser &parser) { AttributeT value; if (parser.parseAttribute(value)) return failure(); @@ -74,7 +74,7 @@ template struct FieldParser::value, IntT>> { - static FailureOr parse(DialectAsmParser &parser) { + static FailureOr parse(AsmParser &parser) { IntT value; if (parser.parseInteger(value)) return failure(); @@ -85,7 +85,7 @@ /// Parse a string. template <> struct FieldParser { - static FailureOr parse(DialectAsmParser &parser) { + static FailureOr parse(AsmParser &parser) { std::string value; if (parser.parseString(&value)) return failure(); @@ -100,7 +100,7 @@ decltype(&ContainerT::push_back)>::value, ContainerT>> { using ElementT = typename ContainerT::value_type; - static FailureOr parse(DialectAsmParser &parser) { + static FailureOr parse(AsmParser &parser) { ContainerT elements; auto elementParser = [&]() { auto element = FieldParser::parse(parser); diff --git a/mlir/lib/Dialect/Async/IR/Async.cpp b/mlir/lib/Dialect/Async/IR/Async.cpp --- a/mlir/lib/Dialect/Async/IR/Async.cpp +++ b/mlir/lib/Dialect/Async/IR/Async.cpp @@ -338,13 +338,13 @@ #define GET_TYPEDEF_CLASSES #include "mlir/Dialect/Async/IR/AsyncOpsTypes.cpp.inc" -void ValueType::print(DialectAsmPrinter &printer) const { +void ValueType::print(AsmPrinter &printer) const { printer << "<"; printer.printType(getValueType()); printer << '>'; } -Type ValueType::parse(mlir::DialectAsmParser &parser) { +Type ValueType::parse(mlir::AsmParser &parser) { Type ty; if (parser.parseLess() || parser.parseType(ty) || parser.parseGreater()) { parser.emitError(parser.getNameLoc(), "failed to parse async value type"); diff --git a/mlir/lib/Dialect/DLTI/DLTI.cpp b/mlir/lib/Dialect/DLTI/DLTI.cpp --- a/mlir/lib/Dialect/DLTI/DLTI.cpp +++ b/mlir/lib/Dialect/DLTI/DLTI.cpp @@ -65,7 +65,7 @@ /// Parses an attribute with syntax: /// attr ::= `#target.` `dl_entry` `<` (type | quoted-string) `,` attr `>` -DataLayoutEntryAttr DataLayoutEntryAttr::parse(DialectAsmParser &parser) { +DataLayoutEntryAttr DataLayoutEntryAttr::parse(AsmParser &parser) { if (failed(parser.parseLess())) return {}; @@ -92,7 +92,7 @@ : get(parser.getBuilder().getIdentifier(identifier), value); } -void DataLayoutEntryAttr::print(DialectAsmPrinter &os) const { +void DataLayoutEntryAttr::print(AsmPrinter &os) const { os << DataLayoutEntryAttr::kAttrKeyword << "<"; if (auto type = getKey().dyn_cast()) os << type; @@ -277,7 +277,7 @@ /// attr ::= `#target.` `dl_spec` `<` attr-list? `>` /// attr-list ::= attr /// | attr `,` attr-list -DataLayoutSpecAttr DataLayoutSpecAttr::parse(DialectAsmParser &parser) { +DataLayoutSpecAttr DataLayoutSpecAttr::parse(AsmParser &parser) { if (failed(parser.parseLess())) return {}; @@ -298,7 +298,7 @@ parser.getContext(), entries); } -void DataLayoutSpecAttr::print(DialectAsmPrinter &os) const { +void DataLayoutSpecAttr::print(AsmPrinter &os) const { os << DataLayoutSpecAttr::kAttrKeyword << "<"; llvm::interleaveComma(getEntries(), os); os << ">"; diff --git a/mlir/lib/Dialect/EmitC/IR/EmitC.cpp b/mlir/lib/Dialect/EmitC/IR/EmitC.cpp --- a/mlir/lib/Dialect/EmitC/IR/EmitC.cpp +++ b/mlir/lib/Dialect/EmitC/IR/EmitC.cpp @@ -166,7 +166,7 @@ #define GET_ATTRDEF_CLASSES #include "mlir/Dialect/EmitC/IR/EmitCAttributes.cpp.inc" -Attribute emitc::OpaqueAttr::parse(DialectAsmParser &parser, Type type) { +Attribute emitc::OpaqueAttr::parse(AsmParser &parser, Type type) { if (parser.parseLess()) return Attribute(); std::string value; @@ -200,7 +200,7 @@ llvm_unreachable("unexpected 'EmitC' attribute kind"); } -void emitc::OpaqueAttr::print(DialectAsmPrinter &printer) const { +void emitc::OpaqueAttr::print(AsmPrinter &printer) const { printer << "<\""; llvm::printEscapedString(getValue(), printer.getStream()); printer << "\">"; @@ -213,7 +213,7 @@ #define GET_TYPEDEF_CLASSES #include "mlir/Dialect/EmitC/IR/EmitCTypes.cpp.inc" -Type emitc::OpaqueType::parse(DialectAsmParser &parser) { +Type emitc::OpaqueType::parse(AsmParser &parser) { if (parser.parseLess()) return Type(); std::string value; @@ -227,7 +227,7 @@ return get(parser.getContext(), value); } -void emitc::OpaqueType::print(DialectAsmPrinter &printer) const { +void emitc::OpaqueType::print(AsmPrinter &printer) const { printer << "<\""; llvm::printEscapedString(getValue(), printer.getStream()); printer << "\">"; diff --git a/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp b/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp --- a/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp +++ b/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp @@ -2425,7 +2425,7 @@ // clang-format on }; -void FMFAttr::print(DialectAsmPrinter &printer) const { +void FMFAttr::print(AsmPrinter &printer) const { printer << "<"; auto flags = llvm::make_filter_range(fastmathFlagsList, [&](auto flag) { return bitEnumContains(this->getFlags(), flag); @@ -2435,7 +2435,7 @@ printer << ">"; } -Attribute FMFAttr::parse(DialectAsmParser &parser, Type type) { +Attribute FMFAttr::parse(AsmParser &parser, Type type) { if (failed(parser.parseLess())) return {}; @@ -2463,7 +2463,7 @@ return FMFAttr::get(parser.getContext(), flags); } -void LinkageAttr::print(DialectAsmPrinter &printer) const { +void LinkageAttr::print(AsmPrinter &printer) const { printer << "<"; if (static_cast(getLinkage()) <= getMaxEnumValForLinkage()) printer << stringifyEnum(getLinkage()); @@ -2472,7 +2472,7 @@ printer << ">"; } -Attribute LinkageAttr::parse(DialectAsmParser &parser, Type type) { +Attribute LinkageAttr::parse(AsmParser &parser, Type type) { StringRef elemName; if (parser.parseLess() || parser.parseKeyword(&elemName) || parser.parseGreater()) @@ -2579,7 +2579,7 @@ return Base::get(context, optionBuilders.options); } -void LoopOptionsAttr::print(DialectAsmPrinter &printer) const { +void LoopOptionsAttr::print(AsmPrinter &printer) const { printer << "<"; llvm::interleaveComma(getOptions(), printer, [&](auto option) { printer << stringifyEnum(option.first) << " = "; @@ -2598,7 +2598,7 @@ printer << ">"; } -Attribute LoopOptionsAttr::parse(DialectAsmParser &parser, Type type) { +Attribute LoopOptionsAttr::parse(AsmParser &parser, Type type) { if (failed(parser.parseLess())) return {}; diff --git a/mlir/lib/Dialect/LLVMIR/IR/LLVMTypeSyntax.cpp b/mlir/lib/Dialect/LLVMIR/IR/LLVMTypeSyntax.cpp --- a/mlir/lib/Dialect/LLVMIR/IR/LLVMTypeSyntax.cpp +++ b/mlir/lib/Dialect/LLVMIR/IR/LLVMTypeSyntax.cpp @@ -23,7 +23,7 @@ /// If the given type is compatible with the LLVM dialect, prints it using /// internal functions to avoid getting a verbose `!llvm` prefix. Otherwise /// prints it as usual. -static void dispatchPrint(DialectAsmPrinter &printer, Type type) { +static void dispatchPrint(AsmPrinter &printer, Type type) { if (isCompatibleType(type) && !type.isa()) return mlir::LLVM::detail::printType(type, printer); printer.printType(type); @@ -51,14 +51,14 @@ /// Prints a structure type. Keeps track of known struct names to handle self- /// or mutually-referring structs without falling into infinite recursion. -static void printStructType(DialectAsmPrinter &printer, LLVMStructType type) { +static void printStructType(AsmPrinter &printer, LLVMStructType type) { // This keeps track of the names of identified structure types that are // currently being printed. Since such types can refer themselves, this // tracking is necessary to stop the recursion: the current function may be - // called recursively from DialectAsmPrinter::printType after the appropriate + // called recursively from AsmPrinter::printType after the appropriate // dispatch. We maintain the invariant of this storage being modified // exclusively in this function, and at most one name being added per call. - // TODO: consider having such functionality inside DialectAsmPrinter. + // TODO: consider having such functionality inside AsmPrinter. thread_local SetVector knownStructNames; unsigned stackSize = knownStructNames.size(); (void)stackSize; @@ -101,15 +101,14 @@ /// Prints a type containing a fixed number of elements. template -static void printArrayOrVectorType(DialectAsmPrinter &printer, TypeTy type) { +static void printArrayOrVectorType(AsmPrinter &printer, TypeTy type) { printer << '<' << type.getNumElements() << " x "; dispatchPrint(printer, type.getElementType()); printer << '>'; } /// Prints a function type. -static void printFunctionType(DialectAsmPrinter &printer, - LLVMFunctionType funcType) { +static void printFunctionType(AsmPrinter &printer, LLVMFunctionType funcType) { printer << '<'; dispatchPrint(printer, funcType.getReturnType()); printer << " ("; @@ -133,7 +132,7 @@ /// struct<"c", (ptr>)>>, /// ptr>)>>)> /// note that "b" is printed twice. -void mlir::LLVM::detail::printType(Type type, DialectAsmPrinter &printer) { +void mlir::LLVM::detail::printType(Type type, AsmPrinter &printer) { if (!type) { printer << "<>"; return; @@ -173,11 +172,11 @@ // Parsing. //===----------------------------------------------------------------------===// -static ParseResult dispatchParse(DialectAsmParser &parser, Type &type); +static ParseResult dispatchParse(AsmParser &parser, Type &type); /// Parses an LLVM dialect function type. /// llvm-type :: = `func<` llvm-type `(` llvm-type-list `...`? `)>` -static LLVMFunctionType parseFunctionType(DialectAsmParser &parser) { +static LLVMFunctionType parseFunctionType(AsmParser &parser) { llvm::SMLoc loc = parser.getCurrentLocation(); Type returnType; if (parser.parseLess() || dispatchParse(parser, returnType) || @@ -216,7 +215,7 @@ /// Parses an LLVM dialect pointer type. /// llvm-type ::= `ptr<` llvm-type (`,` integer)? `>` -static LLVMPointerType parsePointerType(DialectAsmParser &parser) { +static LLVMPointerType parsePointerType(AsmParser &parser) { llvm::SMLoc loc = parser.getCurrentLocation(); Type elementType; if (parser.parseLess() || dispatchParse(parser, elementType)) @@ -234,7 +233,7 @@ /// Parses an LLVM dialect vector type. /// llvm-type ::= `vec<` `? x`? integer `x` llvm-type `>` /// Supports both fixed and scalable vectors. -static Type parseVectorType(DialectAsmParser &parser) { +static Type parseVectorType(AsmParser &parser) { SmallVector dims; llvm::SMLoc dimPos, typePos; Type elementType; @@ -270,7 +269,7 @@ /// Parses an LLVM dialect array type. /// llvm-type ::= `array<` integer `x` llvm-type `>` -static LLVMArrayType parseArrayType(DialectAsmParser &parser) { +static LLVMArrayType parseArrayType(AsmParser &parser) { SmallVector dims; llvm::SMLoc sizePos; Type elementType; @@ -292,7 +291,7 @@ /// error at `subtypesLoc` in case of failure. static LLVMStructType trySetStructBody(LLVMStructType type, ArrayRef subtypes, bool isPacked, - DialectAsmParser &parser, + AsmParser &parser, llvm::SMLoc subtypesLoc) { for (Type t : subtypes) { if (!LLVMStructType::isValidElementType(t)) { @@ -315,14 +314,14 @@ /// `(` llvm-type-list `)` `>` /// | `struct<` string-literal `>` /// | `struct<` string-literal `, opaque>` -static LLVMStructType parseStructType(DialectAsmParser &parser) { +static LLVMStructType parseStructType(AsmParser &parser) { // This keeps track of the names of identified structure types that are // currently being parsed. Since such types can refer themselves, this // tracking is necessary to stop the recursion: the current function may be - // called recursively from DialectAsmParser::parseType after the appropriate + // called recursively from AsmParser::parseType after the appropriate // dispatch. We maintain the invariant of this storage being modified // exclusively in this function, and at most one name being added per call. - // TODO: consider having such functionality inside DialectAsmParser. + // TODO: consider having such functionality inside AsmParser. thread_local SetVector knownStructNames; unsigned stackSize = knownStructNames.size(); (void)stackSize; @@ -417,7 +416,7 @@ /// will try to parse any type in full form (including types with the `!llvm` /// prefix), and on failure fall back to parsing the short-hand version of the /// LLVM dialect types without the `!llvm` prefix. -static Type dispatchParse(DialectAsmParser &parser, bool allowAny = true) { +static Type dispatchParse(AsmParser &parser, bool allowAny = true) { llvm::SMLoc keyLoc = parser.getCurrentLocation(); // Try parsing any MLIR type. @@ -458,7 +457,7 @@ } /// Helper to use in parse lists. -static ParseResult dispatchParse(DialectAsmParser &parser, Type &type) { +static ParseResult dispatchParse(AsmParser &parser, Type &type) { type = dispatchParse(parser); return success(type != nullptr); } diff --git a/mlir/lib/Dialect/PDL/IR/PDLTypes.cpp b/mlir/lib/Dialect/PDL/IR/PDLTypes.cpp --- a/mlir/lib/Dialect/PDL/IR/PDLTypes.cpp +++ b/mlir/lib/Dialect/PDL/IR/PDLTypes.cpp @@ -33,7 +33,7 @@ >(); } -static Type parsePDLType(DialectAsmParser &parser) { +static Type parsePDLType(AsmParser &parser) { StringRef typeTag; if (parser.parseKeyword(&typeTag)) return Type(); @@ -74,7 +74,7 @@ // RangeType //===----------------------------------------------------------------------===// -Type RangeType::parse(DialectAsmParser &parser) { +Type RangeType::parse(AsmParser &parser) { if (parser.parseLess()) return Type(); @@ -92,7 +92,7 @@ return RangeType::get(elementType); } -void RangeType::print(DialectAsmPrinter &printer) const { +void RangeType::print(AsmPrinter &printer) const { printer << "<"; (void)generatedTypePrinter(getElementType(), printer); printer << ">"; diff --git a/mlir/lib/Dialect/SparseTensor/IR/SparseTensorDialect.cpp b/mlir/lib/Dialect/SparseTensor/IR/SparseTensorDialect.cpp --- a/mlir/lib/Dialect/SparseTensor/IR/SparseTensorDialect.cpp +++ b/mlir/lib/Dialect/SparseTensor/IR/SparseTensorDialect.cpp @@ -39,7 +39,7 @@ } } -Attribute SparseTensorEncodingAttr::parse(DialectAsmParser &parser, Type type) { +Attribute SparseTensorEncodingAttr::parse(AsmParser &parser, Type type) { if (failed(parser.parseLess())) return {}; // Parse the data as a dictionary. @@ -117,7 +117,7 @@ map, ptr, ind); } -void SparseTensorEncodingAttr::print(DialectAsmPrinter &printer) const { +void SparseTensorEncodingAttr::print(AsmPrinter &printer) const { // Print the struct-like storage in dictionary fashion. printer << "<{ dimLevelType = [ "; for (unsigned i = 0, e = getDimLevelType().size(); i < e; i++) { diff --git a/mlir/lib/Dialect/Vector/VectorOps.cpp b/mlir/lib/Dialect/Vector/VectorOps.cpp --- a/mlir/lib/Dialect/Vector/VectorOps.cpp +++ b/mlir/lib/Dialect/Vector/VectorOps.cpp @@ -169,7 +169,7 @@ // clang-format on }; -void CombiningKindAttr::print(DialectAsmPrinter &printer) const { +void CombiningKindAttr::print(AsmPrinter &printer) const { printer << "kind<"; auto kinds = llvm::make_filter_range(combiningKindsList, [&](auto kind) { return bitEnumContains(this->getKind(), kind); @@ -179,7 +179,7 @@ printer << ">"; } -Attribute CombiningKindAttr::parse(DialectAsmParser &parser) { +Attribute CombiningKindAttr::parse(AsmParser &parser, Type type) { if (failed(parser.parseLess())) return {}; @@ -207,7 +207,7 @@ return {}; if (attrKind == "kind") - return CombiningKindAttr::parse(parser); + return CombiningKindAttr::parse(parser, {}); parser.emitError(parser.getNameLoc(), "Unknown attribute type: ") << attrKind; return {}; diff --git a/mlir/test/lib/Dialect/Test/TestAttributes.cpp b/mlir/test/lib/Dialect/Test/TestAttributes.cpp --- a/mlir/test/lib/Dialect/Test/TestAttributes.cpp +++ b/mlir/test/lib/Dialect/Test/TestAttributes.cpp @@ -29,15 +29,14 @@ // AttrWithSelfTypeParamAttr //===----------------------------------------------------------------------===// -Attribute AttrWithSelfTypeParamAttr::parse(DialectAsmParser &parser, - Type type) { +Attribute AttrWithSelfTypeParamAttr::parse(AsmParser &parser, Type type) { Type selfType; if (parser.parseType(selfType)) return Attribute(); return get(parser.getContext(), selfType); } -void AttrWithSelfTypeParamAttr::print(DialectAsmPrinter &printer) const { +void AttrWithSelfTypeParamAttr::print(AsmPrinter &printer) const { printer << " " << getType(); } @@ -45,14 +44,14 @@ // AttrWithTypeBuilderAttr //===----------------------------------------------------------------------===// -Attribute AttrWithTypeBuilderAttr::parse(DialectAsmParser &parser, Type type) { +Attribute AttrWithTypeBuilderAttr::parse(AsmParser &parser, Type type) { IntegerAttr element; if (parser.parseAttribute(element)) return Attribute(); return get(parser.getContext(), element); } -void AttrWithTypeBuilderAttr::print(DialectAsmPrinter &printer) const { +void AttrWithTypeBuilderAttr::print(AsmPrinter &printer) const { printer << " " << getAttr(); } @@ -60,7 +59,7 @@ // CompoundAAttr //===----------------------------------------------------------------------===// -Attribute CompoundAAttr::parse(DialectAsmParser &parser, Type type) { +Attribute CompoundAAttr::parse(AsmParser &parser, Type type) { int widthOfSomething; Type oneType; SmallVector arrayOfInts; @@ -81,7 +80,7 @@ return get(parser.getContext(), widthOfSomething, oneType, arrayOfInts); } -void CompoundAAttr::print(DialectAsmPrinter &printer) const { +void CompoundAAttr::print(AsmPrinter &printer) const { printer << "<" << getWidthOfSomething() << ", " << getOneType() << ", ["; llvm::interleaveComma(getArrayOfInts(), printer); printer << "]>"; @@ -91,7 +90,7 @@ // CompoundAAttr //===----------------------------------------------------------------------===// -Attribute TestI64ElementsAttr::parse(DialectAsmParser &parser, Type type) { +Attribute TestI64ElementsAttr::parse(AsmParser &parser, Type type) { SmallVector elements; if (parser.parseLess() || parser.parseLSquare()) return Attribute(); @@ -108,7 +107,7 @@ parser.getContext(), type.cast(), elements); } -void TestI64ElementsAttr::print(DialectAsmPrinter &printer) const { +void TestI64ElementsAttr::print(AsmPrinter &printer) const { printer << "<["; llvm::interleaveComma(getElements(), printer); printer << "] : " << getType() << ">"; @@ -141,7 +140,7 @@ // Utility Functions for Generated Attributes //===----------------------------------------------------------------------===// -static FailureOr> parseIntArray(DialectAsmParser &parser) { +static FailureOr> parseIntArray(AsmParser &parser) { SmallVector ints; if (parser.parseLSquare() || parser.parseCommaSeparatedList([&]() { ints.push_back(0); @@ -152,7 +151,7 @@ return ints; } -static void printIntArray(DialectAsmPrinter &printer, ArrayRef ints) { +static void printIntArray(AsmPrinter &printer, ArrayRef ints) { printer << '['; llvm::interleaveComma(ints, printer); printer << ']'; @@ -162,7 +161,7 @@ // TestSubElementsAccessAttr //===----------------------------------------------------------------------===// -Attribute TestSubElementsAccessAttr::parse(::mlir::DialectAsmParser &parser, +Attribute TestSubElementsAccessAttr::parse(::mlir::AsmParser &parser, ::mlir::Type type) { Attribute first, second, third; if (parser.parseLess() || parser.parseAttribute(first) || @@ -174,8 +173,7 @@ return get(parser.getContext(), first, second, third); } -void TestSubElementsAccessAttr::print( - ::mlir::DialectAsmPrinter &printer) const { +void TestSubElementsAccessAttr::print(::mlir::AsmPrinter &printer) const { printer << "<" << getFirst() << ", " << getSecond() << ", " << getThird() << ">"; } diff --git a/mlir/test/lib/Dialect/Test/TestTypes.h b/mlir/test/lib/Dialect/Test/TestTypes.h --- a/mlir/test/lib/Dialect/Test/TestTypes.h +++ b/mlir/test/lib/Dialect/Test/TestTypes.h @@ -56,7 +56,7 @@ namespace mlir { template <> struct FieldParser { - static FailureOr parse(DialectAsmParser &parser) { + static FailureOr parse(AsmParser &parser) { auto value = FieldParser::parse(parser); if (failed(value)) return failure(); @@ -65,8 +65,8 @@ }; } // end namespace mlir -inline mlir::DialectAsmPrinter &operator<<(mlir::DialectAsmPrinter &printer, - const test::CustomParam ¶m) { +inline mlir::AsmPrinter &operator<<(mlir::AsmPrinter &printer, + const test::CustomParam ¶m) { return printer << param.value; } diff --git a/mlir/test/lib/Dialect/Test/TestTypes.cpp b/mlir/test/lib/Dialect/Test/TestTypes.cpp --- a/mlir/test/lib/Dialect/Test/TestTypes.cpp +++ b/mlir/test/lib/Dialect/Test/TestTypes.cpp @@ -26,7 +26,7 @@ // Custom parser for SignednessSemantics. static ParseResult -parseSignedness(DialectAsmParser &parser, +parseSignedness(AsmParser &parser, TestIntegerType::SignednessSemantics &result) { StringRef signStr; auto loc = parser.getCurrentLocation(); @@ -46,7 +46,7 @@ } // Custom printer for SignednessSemantics. -static void printSignedness(DialectAsmPrinter &printer, +static void printSignedness(AsmPrinter &printer, const TestIntegerType::SignednessSemantics &ss) { switch (ss) { case TestIntegerType::SignednessSemantics::Unsigned: @@ -87,7 +87,7 @@ // CompoundAType //===----------------------------------------------------------------------===// -Type CompoundAType::parse(DialectAsmParser &parser) { +Type CompoundAType::parse(AsmParser &parser) { int widthOfSomething; Type oneType; SmallVector arrayOfInts; @@ -108,7 +108,7 @@ return get(parser.getContext(), widthOfSomething, oneType, arrayOfInts); } -void CompoundAType::print(DialectAsmPrinter &printer) const { +void CompoundAType::print(AsmPrinter &printer) const { printer << "<" << getWidthOfSomething() << ", " << getOneType() << ", ["; auto intArray = getArrayOfInts(); llvm::interleaveComma(intArray, printer); @@ -141,14 +141,14 @@ // TestTypeWithLayout //===----------------------------------------------------------------------===// -Type TestTypeWithLayoutType::parse(DialectAsmParser &parser) { +Type TestTypeWithLayoutType::parse(AsmParser &parser) { unsigned val; if (parser.parseLess() || parser.parseInteger(val) || parser.parseGreater()) return Type(); return TestTypeWithLayoutType::get(parser.getContext(), val); } -void TestTypeWithLayoutType::print(DialectAsmPrinter &printer) const { +void TestTypeWithLayoutType::print(AsmPrinter &printer) const { printer << "<" << getKey() << ">"; } @@ -234,7 +234,7 @@ SimpleAType::attachInterface(*getContext()); } -static Type parseTestType(DialectAsmParser &parser, SetVector &stack) { +static Type parseTestType(AsmParser &parser, SetVector &stack) { StringRef typeTag; if (failed(parser.parseKeyword(&typeTag))) return Type(); @@ -281,7 +281,7 @@ return parseTestType(parser, stack); } -static void printTestType(Type type, DialectAsmPrinter &printer, +static void printTestType(Type type, AsmPrinter &printer, SetVector &stack) { if (succeeded(generatedTypePrinter(type, printer))) return; diff --git a/mlir/test/mlir-tblgen/attr-or-type-format.td b/mlir/test/mlir-tblgen/attr-or-type-format.td --- a/mlir/test/mlir-tblgen/attr-or-type-format.td +++ b/mlir/test/mlir-tblgen/attr-or-type-format.td @@ -34,7 +34,7 @@ /// Check simple attribute parser and printer are generated correctly. -// ATTR: ::mlir::Attribute TestAAttr::parse(::mlir::DialectAsmParser &parser, +// ATTR: ::mlir::Attribute TestAAttr::parse(::mlir::AsmParser &parser, // ATTR: ::mlir::Type attrType) { // ATTR: FailureOr _result_value; // ATTR: FailureOr _result_complex; @@ -57,7 +57,7 @@ // ATTR: _result_complex.getValue()); // ATTR: } -// ATTR: void TestAAttr::print(::mlir::DialectAsmPrinter &printer) const { +// ATTR: void TestAAttr::print(::mlir::AsmPrinter &printer) const { // ATTR: printer << ' ' << "hello"; // ATTR: printer << ' ' << "="; // ATTR: printer << ' '; @@ -80,7 +80,7 @@ /// Test simple struct parser and printer are generated correctly. -// ATTR: ::mlir::Attribute TestBAttr::parse(::mlir::DialectAsmParser &parser, +// ATTR: ::mlir::Attribute TestBAttr::parse(::mlir::AsmParser &parser, // ATTR: ::mlir::Type attrType) { // ATTR: bool _seen_v0 = false; // ATTR: bool _seen_v1 = false; @@ -111,7 +111,7 @@ // ATTR: _result_v1.getValue()); // ATTR: } -// ATTR: void TestBAttr::print(::mlir::DialectAsmPrinter &printer) const { +// ATTR: void TestBAttr::print(::mlir::AsmPrinter &printer) const { // ATTR: printer << "v0"; // ATTR: printer << ' ' << "="; // ATTR: printer << ' '; @@ -135,7 +135,7 @@ /// Test attribute with capture-all params has correct parser and printer. -// ATTR: ::mlir::Attribute TestFAttr::parse(::mlir::DialectAsmParser &parser, +// ATTR: ::mlir::Attribute TestFAttr::parse(::mlir::AsmParser &parser, // ATTR: ::mlir::Type attrType) { // ATTR: ::mlir::FailureOr _result_v0; // ATTR: ::mlir::FailureOr _result_v1; @@ -152,7 +152,7 @@ // ATTR: _result_v1.getValue()); // ATTR: } -// ATTR: void TestFAttr::print(::mlir::DialectAsmPrinter &printer) const { +// ATTR: void TestFAttr::print(::mlir::AsmPrinter &printer) const { // ATTR: printer << ' '; // ATTR: printer << getV0(); // ATTR: printer << ","; @@ -170,7 +170,7 @@ /// Test type parser and printer that mix variables and struct are generated /// correctly. -// TYPE: ::mlir::Type TestCType::parse(::mlir::DialectAsmParser &parser) { +// TYPE: ::mlir::Type TestCType::parse(::mlir::AsmParser &parser) { // TYPE: FailureOr _result_value; // TYPE: FailureOr _result_complex; // TYPE: if (parser.parseKeyword("foo")) @@ -206,7 +206,7 @@ // TYPE: return {}; // TYPE: } -// TYPE: void TestCType::print(::mlir::DialectAsmPrinter &printer) const { +// TYPE: void TestCType::print(::mlir::AsmPrinter &printer) const { // TYPE: printer << ' ' << "foo"; // TYPE: printer << ","; // TYPE: printer << ' ' << ":"; @@ -234,7 +234,7 @@ /// Test type parser and printer with mix of variables and struct are generated /// correctly. -// TYPE: ::mlir::Type TestDType::parse(::mlir::DialectAsmParser &parser) { +// TYPE: ::mlir::Type TestDType::parse(::mlir::AsmParser &parser) { // TYPE: _result_v0 = ::parseTypeParamC(parser); // TYPE: if (failed(_result_v0)) // TYPE: return {}; @@ -272,7 +272,7 @@ // TYPE: _result_v3.getValue()); // TYPE: } -// TYPE: void TestDType::print(::mlir::DialectAsmPrinter &printer) const { +// TYPE: void TestDType::print(::mlir::AsmPrinter &printer) const { // TYPE: printer << getV0(); // TYPE: myPrinter(getV1()); // TYPE: printer << ' ' << "v2"; @@ -297,7 +297,7 @@ /// Type test with two struct directives has correctly generated parser and /// printer. -// TYPE: ::mlir::Type TestEType::parse(::mlir::DialectAsmParser &parser) { +// TYPE: ::mlir::Type TestEType::parse(::mlir::AsmParser &parser) { // TYPE: FailureOr _result_v0; // TYPE: FailureOr _result_v1; // TYPE: FailureOr _result_v2; @@ -357,7 +357,7 @@ // TYPE: _result_v3.getValue()); // TYPE: } -// TYPE: void TestEType::print(::mlir::DialectAsmPrinter &printer) const { +// TYPE: void TestEType::print(::mlir::AsmPrinter &printer) const { // TYPE: printer << "v0"; // TYPE: printer << ' ' << "="; // TYPE: printer << ' '; diff --git a/mlir/test/mlir-tblgen/attrdefs.td b/mlir/test/mlir-tblgen/attrdefs.td --- a/mlir/test/mlir-tblgen/attrdefs.td +++ b/mlir/test/mlir-tblgen/attrdefs.td @@ -19,7 +19,7 @@ // DEF: ::test::SingleParameterAttr // DEF-LABEL: ::mlir::OptionalParseResult generatedAttributeParser( -// DEF-NEXT: ::mlir::DialectAsmParser &parser, +// DEF-NEXT: ::mlir::AsmParser &parser, // DEF-NEXT: ::llvm::StringRef mnemonic, ::mlir::Type type, // DEF-NEXT: ::mlir::Attribute &value) { // DEF: if (mnemonic == ::test::CompoundAAttr::getMnemonic()) { @@ -67,8 +67,8 @@ // DECL: return ::llvm::StringLiteral("cmpnd_a"); // DECL: } // DECL: static ::mlir::Attribute parse( -// DECL-SAME: ::mlir::DialectAsmParser &parser, ::mlir::Type type); -// DECL: void print(::mlir::DialectAsmPrinter &printer) const; +// DECL-SAME: ::mlir::AsmParser &parser, ::mlir::Type type); +// DECL: void print(::mlir::AsmPrinter &printer) const; // DECL: int getWidthOfSomething() const; // DECL: ::test::SimpleTypeA getExampleTdType() const; // DECL: ::llvm::APFloat getApFloat() const; @@ -111,8 +111,8 @@ // DECL: return ::llvm::StringLiteral("index"); // DECL: } // DECL: static ::mlir::Attribute parse( -// DECL-SAME: ::mlir::DialectAsmParser &parser, ::mlir::Type type); -// DECL: void print(::mlir::DialectAsmPrinter &printer) const; +// DECL-SAME: ::mlir::AsmParser &parser, ::mlir::Type type); +// DECL: void print(::mlir::AsmPrinter &printer) const; } def D_SingleParameterAttr : TestAttr<"SingleParameter"> { diff --git a/mlir/test/mlir-tblgen/typedefs.td b/mlir/test/mlir-tblgen/typedefs.td --- a/mlir/test/mlir-tblgen/typedefs.td +++ b/mlir/test/mlir-tblgen/typedefs.td @@ -7,8 +7,8 @@ // DECL: #undef GET_TYPEDEF_CLASSES // DECL: namespace mlir { -// DECL: class DialectAsmParser; -// DECL: class DialectAsmPrinter; +// DECL: class AsmParser; +// DECL: class AsmPrinter; // DECL: } // namespace mlir // DEF: #ifdef GET_TYPEDEF_LIST @@ -20,7 +20,7 @@ // DEF: ::test::IntegerType // DEF-LABEL: ::mlir::OptionalParseResult generatedTypeParser( -// DEF-NEXT: ::mlir::DialectAsmParser &parser, +// DEF-NEXT: ::mlir::AsmParser &parser, // DEF-NEXT: ::llvm::StringRef mnemonic, // DEF-NEXT: ::mlir::Type &value) { // DEF: if (mnemonic == ::test::CompoundAType::getMnemonic()) { @@ -71,8 +71,8 @@ // DECL: static constexpr ::llvm::StringLiteral getMnemonic() { // DECL: return ::llvm::StringLiteral("cmpnd_a"); // DECL: } -// DECL: static ::mlir::Type parse(::mlir::DialectAsmParser &parser); -// DECL: void print(::mlir::DialectAsmPrinter &printer) const; +// DECL: static ::mlir::Type parse(::mlir::AsmParser &parser); +// DECL: void print(::mlir::AsmPrinter &printer) const; // DECL: int getWidthOfSomething() const; // DECL: ::test::SimpleTypeA getExampleTdType() const; // DECL: SomeCppStruct getExampleCppType() const; @@ -90,8 +90,8 @@ // DECL: static constexpr ::llvm::StringLiteral getMnemonic() { // DECL: return ::llvm::StringLiteral("index"); // DECL: } -// DECL: static ::mlir::Type parse(::mlir::DialectAsmParser &parser); -// DECL: void print(::mlir::DialectAsmPrinter &printer) const; +// DECL: static ::mlir::Type parse(::mlir::AsmParser &parser); +// DECL: void print(::mlir::AsmPrinter &printer) const; } def D_SingleParameterType : TestType<"SingleParameter"> { diff --git a/mlir/tools/mlir-tblgen/AttrOrTypeDefGen.cpp b/mlir/tools/mlir-tblgen/AttrOrTypeDefGen.cpp --- a/mlir/tools/mlir-tblgen/AttrOrTypeDefGen.cpp +++ b/mlir/tools/mlir-tblgen/AttrOrTypeDefGen.cpp @@ -210,7 +210,9 @@ /// later on. static const char *const typeDefDeclHeader = R"( namespace mlir { +class AsmParser; class DialectAsmParser; +class AsmPrinter; class DialectAsmPrinter; } // namespace mlir )"; @@ -256,8 +258,8 @@ /// {0}: The name of the base value type, e.g. Attribute or Type. /// {1}: Extra parser parameters. static const char *const defDeclParsePrintStr = R"( - static ::mlir::{0} parse(::mlir::DialectAsmParser &parser{1}); - void print(::mlir::DialectAsmPrinter &printer) const; + static ::mlir::{0} parse(::mlir::AsmParser &parser{1}); + void print(::mlir::AsmPrinter &printer) const; )"; /// The code block for the verify method declaration. @@ -495,7 +497,7 @@ /// {1}: Additional parser parameters. static const char *const defParserDispatchStartStr = R"( static ::mlir::OptionalParseResult generated{0}Parser( - ::mlir::DialectAsmParser &parser, + ::mlir::AsmParser &parser, ::llvm::StringRef mnemonic{1}, ::mlir::{0} &value) {{ )"; @@ -559,7 +561,7 @@ /// {0}: The name of the base value type, e.g. Attribute or Type. static const char *const defPrinterDispatchStartStr = R"( static ::mlir::LogicalResult generated{0}Printer( - ::mlir::{0} def, ::mlir::DialectAsmPrinter &printer) {{ + ::mlir::{0} def, ::mlir::AsmPrinter &printer) {{ return ::llvm::TypeSwitch<::mlir::{0}, ::mlir::LogicalResult>(def) )"; @@ -794,7 +796,7 @@ // Both the mnenomic and printerCode must be defined (for parity with // parserCode). os << "void " << def.getCppClassName() - << "::print(::mlir::DialectAsmPrinter &printer) const {\n"; + << "::print(::mlir::AsmPrinter &printer) const {\n"; if (printerCode->empty()) { // If no code specified, emit error. PrintFatalError(def.getLoc(), @@ -813,7 +815,7 @@ // The mnenomic must be defined so the dispatcher knows how to dispatch. os << llvm::formatv("::mlir::{0} {1}::parse(" - "::mlir::DialectAsmParser &parser", + "::mlir::AsmParser &parser", valueType, def.getCppClassName()); if (isAttrGenerator) { // Attributes also accept a type parameter instead of a context. diff --git a/mlir/tools/mlir-tblgen/AttrOrTypeFormatGen.cpp b/mlir/tools/mlir-tblgen/AttrOrTypeFormatGen.cpp --- a/mlir/tools/mlir-tblgen/AttrOrTypeFormatGen.cpp +++ b/mlir/tools/mlir-tblgen/AttrOrTypeFormatGen.cpp @@ -162,7 +162,7 @@ /// /// $0: The attribute C++ class name. static const char *const attrParserDefn = R"( -::mlir::Attribute $0::parse(::mlir::DialectAsmParser &$_parser, +::mlir::Attribute $0::parse(::mlir::AsmParser &$_parser, ::mlir::Type $_type) { )"; @@ -170,7 +170,7 @@ /// /// $0: The type C++ class name. static const char *const typeParserDefn = R"( -::mlir::Type $0::parse(::mlir::DialectAsmParser &$_parser) { +::mlir::Type $0::parse(::mlir::AsmParser &$_parser) { )"; /// Default parser for attribute or type parameters. @@ -190,7 +190,7 @@ /// /// $0: The attribute or type C++ class name. static const char *const attrOrTypePrinterDefn = R"( -void $0::print(::mlir::DialectAsmPrinter &$_printer) const { +void $0::print(::mlir::AsmPrinter &$_printer) const { )"; /// Loop declaration for struct parser.