[flang-commits] [flang] f97e72a - Use base class AsmParser/AsmPrinter in Types and Attribute print/parse method (NFC)
Mehdi Amini via flang-commits
flang-commits at lists.llvm.org
Wed Nov 10 22:26:49 PST 2021
Author: Mehdi Amini
Date: 2021-11-11T06:26:33Z
New Revision: f97e72aaca4a7534341f67a8f93fa3246882622a
URL: https://github.com/llvm/llvm-project/commit/f97e72aaca4a7534341f67a8f93fa3246882622a
DIFF: https://github.com/llvm/llvm-project/commit/f97e72aaca4a7534341f67a8f93fa3246882622a.diff
LOG: Use base class AsmParser/AsmPrinter in Types and Attribute print/parse method (NFC)
This decouples the printing/parsing from the "context" in which the parsing occurs.
This will allow to invoke these methods directly using an OpAsmParser/OpAsmPrinter.
Differential Revision: https://reviews.llvm.org/D113637
Added:
Modified:
flang/lib/Optimizer/Dialect/FIRType.cpp
mlir/include/mlir/Dialect/DLTI/DLTI.h
mlir/include/mlir/Dialect/LLVMIR/LLVMTypes.h
mlir/include/mlir/Dialect/Vector/VectorOps.h
mlir/include/mlir/IR/DialectImplementation.h
mlir/lib/Dialect/Async/IR/Async.cpp
mlir/lib/Dialect/DLTI/DLTI.cpp
mlir/lib/Dialect/EmitC/IR/EmitC.cpp
mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
mlir/lib/Dialect/LLVMIR/IR/LLVMTypeSyntax.cpp
mlir/lib/Dialect/PDL/IR/PDLTypes.cpp
mlir/lib/Dialect/SparseTensor/IR/SparseTensorDialect.cpp
mlir/lib/Dialect/Vector/VectorOps.cpp
mlir/test/lib/Dialect/Test/TestAttributes.cpp
mlir/test/lib/Dialect/Test/TestTypes.cpp
mlir/test/lib/Dialect/Test/TestTypes.h
mlir/test/mlir-tblgen/attr-or-type-format.td
mlir/test/mlir-tblgen/attrdefs.td
mlir/test/mlir-tblgen/typedefs.td
mlir/tools/mlir-tblgen/AttrOrTypeDefGen.cpp
mlir/tools/mlir-tblgen/AttrOrTypeFormatGen.cpp
Removed:
################################################################################
diff --git a/flang/lib/Optimizer/Dialect/FIRType.cpp b/flang/lib/Optimizer/Dialect/FIRType.cpp
index 2c6cf72bb6863..c90a88b781132 100644
--- a/flang/lib/Optimizer/Dialect/FIRType.cpp
+++ b/flang/lib/Optimizer/Dialect/FIRType.cpp
@@ -29,7 +29,7 @@ using namespace fir;
namespace {
template <typename TYPE>
-TYPE parseIntSingleton(mlir::DialectAsmParser &parser) {
+TYPE parseIntSingleton(mlir::AsmParser &parser) {
int kind = 0;
if (parser.parseLess() || parser.parseInteger(kind) || parser.parseGreater())
return {};
@@ -37,17 +37,17 @@ TYPE parseIntSingleton(mlir::DialectAsmParser &parser) {
}
template <typename TYPE>
-TYPE parseKindSingleton(mlir::DialectAsmParser &parser) {
+TYPE parseKindSingleton(mlir::AsmParser &parser) {
return parseIntSingleton<TYPE>(parser);
}
template <typename TYPE>
-TYPE parseRankSingleton(mlir::DialectAsmParser &parser) {
+TYPE parseRankSingleton(mlir::AsmParser &parser) {
return parseIntSingleton<TYPE>(parser);
}
template <typename TYPE>
-TYPE parseTypeSingleton(mlir::DialectAsmParser &parser) {
+TYPE parseTypeSingleton(mlir::AsmParser &parser) {
mlir::Type ty;
if (parser.parseLess() || parser.parseType(ty) || parser.parseGreater())
return {};
@@ -74,7 +74,7 @@ bool verifySameLists(llvm::ArrayRef<RecordType::TypePair> a1,
return a1 == a2;
}
-RecordType verifyDerived(mlir::DialectAsmParser &parser, RecordType derivedTy,
+RecordType verifyDerived(mlir::AsmParser &parser, RecordType derivedTy,
llvm::ArrayRef<RecordType::TypePair> lenPList,
llvm::ArrayRef<RecordType::TypePair> typeList) {
auto loc = parser.getNameLoc();
@@ -286,14 +286,14 @@ bool fir::isa_unknown_size_box(mlir::Type t) {
//===----------------------------------------------------------------------===//
// `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 {};
return get(parser.getContext(), ty);
}
-void fir::BoxProcType::print(mlir::DialectAsmPrinter &printer) const {
+void fir::BoxProcType::print(mlir::AsmPrinter &printer) const {
printer << "<" << getEleTy() << '>';
}
@@ -319,7 +319,7 @@ static bool cannotBePointerOrHeapElementType(mlir::Type eleTy) {
//===----------------------------------------------------------------------===//
// `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 {};
@@ -336,7 +336,7 @@ mlir::Type fir::BoxType::parse(mlir::DialectAsmParser &parser) {
return get(ofTy, map);
}
-void fir::BoxType::print(mlir::DialectAsmPrinter &printer) const {
+void fir::BoxType::print(mlir::AsmPrinter &printer) const {
printer << "<" << getEleTy();
if (auto map = getLayoutMap()) {
printer << ", " << map;
@@ -355,11 +355,11 @@ fir::BoxType::verify(llvm::function_ref<mlir::InFlightDiagnostic()> emitError,
// BoxCharType
//===----------------------------------------------------------------------===//
-mlir::Type fir::BoxCharType::parse(mlir::DialectAsmParser &parser) {
+mlir::Type fir::BoxCharType::parse(mlir::AsmParser &parser) {
return parseKindSingleton<fir::BoxCharType>(parser);
}
-void fir::BoxCharType::print(mlir::DialectAsmPrinter &printer) const {
+void fir::BoxCharType::print(mlir::AsmPrinter &printer) const {
printer << "<" << getKind() << ">";
}
@@ -377,7 +377,7 @@ CharacterType fir::BoxCharType::getEleTy() const {
//===----------------------------------------------------------------------===//
// `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 {};
@@ -394,7 +394,7 @@ mlir::Type fir::CharacterType::parse(mlir::DialectAsmParser &parser) {
return get(parser.getContext(), kind, len);
}
-void fir::CharacterType::print(mlir::DialectAsmPrinter &printer) const {
+void fir::CharacterType::print(mlir::AsmPrinter &printer) const {
printer << "<" << getFKind();
auto len = getLen();
if (len != fir::CharacterType::singleton()) {
@@ -411,11 +411,11 @@ void fir::CharacterType::print(mlir::DialectAsmPrinter &printer) const {
// ComplexType
//===----------------------------------------------------------------------===//
-mlir::Type fir::ComplexType::parse(mlir::DialectAsmParser &parser) {
+mlir::Type fir::ComplexType::parse(mlir::AsmParser &parser) {
return parseKindSingleton<fir::ComplexType>(parser);
}
-void fir::ComplexType::print(mlir::DialectAsmPrinter &printer) const {
+void fir::ComplexType::print(mlir::AsmPrinter &printer) const {
printer << "<" << getFKind() << '>';
}
@@ -428,11 +428,11 @@ mlir::Type fir::ComplexType::getElementType() const {
//===----------------------------------------------------------------------===//
// `heap` `<` type `>`
-mlir::Type fir::HeapType::parse(mlir::DialectAsmParser &parser) {
+mlir::Type fir::HeapType::parse(mlir::AsmParser &parser) {
return parseTypeSingleton<HeapType>(parser);
}
-void fir::HeapType::print(mlir::DialectAsmPrinter &printer) const {
+void fir::HeapType::print(mlir::AsmPrinter &printer) const {
printer << "<" << getEleTy() << '>';
}
@@ -450,11 +450,11 @@ fir::HeapType::verify(llvm::function_ref<mlir::InFlightDiagnostic()> emitError,
//===----------------------------------------------------------------------===//
// `int` `<` kind `>`
-mlir::Type fir::IntegerType::parse(mlir::DialectAsmParser &parser) {
+mlir::Type fir::IntegerType::parse(mlir::AsmParser &parser) {
return parseKindSingleton<fir::IntegerType>(parser);
}
-void fir::IntegerType::print(mlir::DialectAsmPrinter &printer) const {
+void fir::IntegerType::print(mlir::AsmPrinter &printer) const {
printer << "<" << getFKind() << '>';
}
@@ -463,11 +463,11 @@ void fir::IntegerType::print(mlir::DialectAsmPrinter &printer) const {
//===----------------------------------------------------------------------===//
// `logical` `<` kind `>`
-mlir::Type fir::LogicalType::parse(mlir::DialectAsmParser &parser) {
+mlir::Type fir::LogicalType::parse(mlir::AsmParser &parser) {
return parseKindSingleton<fir::LogicalType>(parser);
}
-void fir::LogicalType::print(mlir::DialectAsmPrinter &printer) const {
+void fir::LogicalType::print(mlir::AsmPrinter &printer) const {
printer << "<" << getFKind() << '>';
}
@@ -476,11 +476,11 @@ void fir::LogicalType::print(mlir::DialectAsmPrinter &printer) const {
//===----------------------------------------------------------------------===//
// `ptr` `<` type `>`
-mlir::Type fir::PointerType::parse(mlir::DialectAsmParser &parser) {
+mlir::Type fir::PointerType::parse(mlir::AsmParser &parser) {
return parseTypeSingleton<fir::PointerType>(parser);
}
-void fir::PointerType::print(mlir::DialectAsmPrinter &printer) const {
+void fir::PointerType::print(mlir::AsmPrinter &printer) const {
printer << "<" << getEleTy() << '>';
}
@@ -497,11 +497,11 @@ mlir::LogicalResult fir::PointerType::verify(
//===----------------------------------------------------------------------===//
// `real` `<` kind `>`
-mlir::Type fir::RealType::parse(mlir::DialectAsmParser &parser) {
+mlir::Type fir::RealType::parse(mlir::AsmParser &parser) {
return parseKindSingleton<fir::RealType>(parser);
}
-void fir::RealType::print(mlir::DialectAsmPrinter &printer) const {
+void fir::RealType::print(mlir::AsmPrinter &printer) const {
printer << "<" << getFKind() << '>';
}
@@ -520,7 +520,7 @@ fir::RealType::verify(llvm::function_ref<mlir::InFlightDiagnostic()> emitError,
// `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 {};
@@ -572,7 +572,7 @@ mlir::Type fir::RecordType::parse(mlir::DialectAsmParser &parser) {
return verifyDerived(parser, result, lenParamList, typeList);
}
-void fir::RecordType::print(mlir::DialectAsmPrinter &printer) const {
+void fir::RecordType::print(mlir::AsmPrinter &printer) const {
printer << "<" << getName();
if (!recordTypeVisited.count(uniqueKey())) {
recordTypeVisited.insert(uniqueKey());
@@ -647,11 +647,11 @@ unsigned fir::RecordType::getFieldIndex(llvm::StringRef ident) {
//===----------------------------------------------------------------------===//
// `ref` `<` type `>`
-mlir::Type fir::ReferenceType::parse(mlir::DialectAsmParser &parser) {
+mlir::Type fir::ReferenceType::parse(mlir::AsmParser &parser) {
return parseTypeSingleton<fir::ReferenceType>(parser);
}
-void fir::ReferenceType::print(mlir::DialectAsmPrinter &printer) const {
+void fir::ReferenceType::print(mlir::AsmPrinter &printer) const {
printer << "<" << getEleTy() << '>';
}
@@ -670,7 +670,7 @@ mlir::LogicalResult fir::ReferenceType::verify(
// `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;
@@ -692,7 +692,7 @@ mlir::Type fir::SequenceType::parse(mlir::DialectAsmParser &parser) {
return SequenceType::get(parser.getContext(), shape, eleTy, map);
}
-void fir::SequenceType::print(mlir::DialectAsmPrinter &printer) const {
+void fir::SequenceType::print(mlir::AsmPrinter &printer) const {
auto shape = getShape();
if (shape.size()) {
printer << '<';
@@ -758,11 +758,11 @@ mlir::LogicalResult fir::SequenceType::verify(
// ShapeType
//===----------------------------------------------------------------------===//
-mlir::Type fir::ShapeType::parse(mlir::DialectAsmParser &parser) {
+mlir::Type fir::ShapeType::parse(mlir::AsmParser &parser) {
return parseRankSingleton<fir::ShapeType>(parser);
}
-void fir::ShapeType::print(mlir::DialectAsmPrinter &printer) const {
+void fir::ShapeType::print(mlir::AsmPrinter &printer) const {
printer << "<" << getImpl()->rank << ">";
}
@@ -770,11 +770,11 @@ void fir::ShapeType::print(mlir::DialectAsmPrinter &printer) const {
// ShapeShiftType
//===----------------------------------------------------------------------===//
-mlir::Type fir::ShapeShiftType::parse(mlir::DialectAsmParser &parser) {
+mlir::Type fir::ShapeShiftType::parse(mlir::AsmParser &parser) {
return parseRankSingleton<fir::ShapeShiftType>(parser);
}
-void fir::ShapeShiftType::print(mlir::DialectAsmPrinter &printer) const {
+void fir::ShapeShiftType::print(mlir::AsmPrinter &printer) const {
printer << "<" << getRank() << ">";
}
@@ -782,11 +782,11 @@ void fir::ShapeShiftType::print(mlir::DialectAsmPrinter &printer) const {
// ShiftType
//===----------------------------------------------------------------------===//
-mlir::Type fir::ShiftType::parse(mlir::DialectAsmParser &parser) {
+mlir::Type fir::ShiftType::parse(mlir::AsmParser &parser) {
return parseRankSingleton<fir::ShiftType>(parser);
}
-void fir::ShiftType::print(mlir::DialectAsmPrinter &printer) const {
+void fir::ShiftType::print(mlir::AsmPrinter &printer) const {
printer << "<" << getRank() << ">";
}
@@ -795,11 +795,11 @@ void fir::ShiftType::print(mlir::DialectAsmPrinter &printer) const {
//===----------------------------------------------------------------------===//
// `slice` `<` rank `>`
-mlir::Type fir::SliceType::parse(mlir::DialectAsmParser &parser) {
+mlir::Type fir::SliceType::parse(mlir::AsmParser &parser) {
return parseRankSingleton<fir::SliceType>(parser);
}
-void fir::SliceType::print(mlir::DialectAsmPrinter &printer) const {
+void fir::SliceType::print(mlir::AsmPrinter &printer) const {
printer << "<" << getRank() << '>';
}
@@ -808,11 +808,11 @@ void fir::SliceType::print(mlir::DialectAsmPrinter &printer) const {
//===----------------------------------------------------------------------===//
// `tdesc` `<` type `>`
-mlir::Type fir::TypeDescType::parse(mlir::DialectAsmParser &parser) {
+mlir::Type fir::TypeDescType::parse(mlir::AsmParser &parser) {
return parseTypeSingleton<fir::TypeDescType>(parser);
}
-void fir::TypeDescType::print(mlir::DialectAsmPrinter &printer) const {
+void fir::TypeDescType::print(mlir::AsmPrinter &printer) const {
printer << "<" << getOfTy() << '>';
}
@@ -832,7 +832,7 @@ mlir::LogicalResult fir::TypeDescType::verify(
//===----------------------------------------------------------------------===//
// `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() ||
@@ -841,7 +841,7 @@ mlir::Type fir::VectorType::parse(mlir::DialectAsmParser &parser) {
return fir::VectorType::get(len, eleTy);
}
-void fir::VectorType::print(mlir::DialectAsmPrinter &printer) const {
+void fir::VectorType::print(mlir::AsmPrinter &printer) const {
printer << "<" << getLen() << ':' << getEleTy() << '>';
}
diff --git a/mlir/include/mlir/Dialect/DLTI/DLTI.h b/mlir/include/mlir/Dialect/DLTI/DLTI.h
index fdaa3122cedba..c80b45bbe804f 100644
--- a/mlir/include/mlir/Dialect/DLTI/DLTI.h
+++ b/mlir/include/mlir/Dialect/DLTI/DLTI.h
@@ -51,10 +51,10 @@ class DataLayoutEntryAttr
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 @@ class DataLayoutSpecAttr
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
index 150d62fcd5d9f..3de4f3ab60dbe 100644
--- a/mlir/include/mlir/Dialect/LLVMIR/LLVMTypes.h
+++ b/mlir/include/mlir/Dialect/LLVMIR/LLVMTypes.h
@@ -24,8 +24,8 @@ class TypeSize;
namespace mlir {
-class DialectAsmParser;
-class DialectAsmPrinter;
+class AsmParser;
+class AsmPrinter;
namespace LLVM {
class LLVMDialect;
@@ -419,7 +419,7 @@ namespace detail {
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
index 39d8a1917a201..1671cc708110e 100644
--- a/mlir/include/mlir/Dialect/Vector/VectorOps.h
+++ b/mlir/include/mlir/Dialect/Vector/VectorOps.h
@@ -101,8 +101,8 @@ class CombiningKindAttr
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
index 9302eb9146d4b..b841135ca1a9c 100644
--- a/mlir/include/mlir/IR/DialectImplementation.h
+++ b/mlir/include/mlir/IR/DialectImplementation.h
@@ -62,7 +62,7 @@ template <typename AttributeT>
struct FieldParser<
AttributeT, std::enable_if_t<std::is_base_of<Attribute, AttributeT>::value,
AttributeT>> {
- static FailureOr<AttributeT> parse(DialectAsmParser &parser) {
+ static FailureOr<AttributeT> parse(AsmParser &parser) {
AttributeT value;
if (parser.parseAttribute(value))
return failure();
@@ -74,7 +74,7 @@ struct FieldParser<
template <typename IntT>
struct FieldParser<IntT,
std::enable_if_t<std::is_integral<IntT>::value, IntT>> {
- static FailureOr<IntT> parse(DialectAsmParser &parser) {
+ static FailureOr<IntT> parse(AsmParser &parser) {
IntT value;
if (parser.parseInteger(value))
return failure();
@@ -85,7 +85,7 @@ struct FieldParser<IntT,
/// Parse a string.
template <>
struct FieldParser<std::string> {
- static FailureOr<std::string> parse(DialectAsmParser &parser) {
+ static FailureOr<std::string> parse(AsmParser &parser) {
std::string value;
if (parser.parseString(&value))
return failure();
@@ -100,7 +100,7 @@ struct FieldParser<
decltype(&ContainerT::push_back)>::value,
ContainerT>> {
using ElementT = typename ContainerT::value_type;
- static FailureOr<ContainerT> parse(DialectAsmParser &parser) {
+ static FailureOr<ContainerT> parse(AsmParser &parser) {
ContainerT elements;
auto elementParser = [&]() {
auto element = FieldParser<ElementT>::parse(parser);
diff --git a/mlir/lib/Dialect/Async/IR/Async.cpp b/mlir/lib/Dialect/Async/IR/Async.cpp
index 0582980e75635..acae4cdba18d2 100644
--- a/mlir/lib/Dialect/Async/IR/Async.cpp
+++ b/mlir/lib/Dialect/Async/IR/Async.cpp
@@ -338,13 +338,13 @@ static LogicalResult verify(AwaitOp op) {
#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
index 243e7865be1a5..b18f3db600228 100644
--- a/mlir/lib/Dialect/DLTI/DLTI.cpp
+++ b/mlir/lib/Dialect/DLTI/DLTI.cpp
@@ -65,7 +65,7 @@ Attribute DataLayoutEntryAttr::getValue() const { return getImpl()->value; }
/// 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 @@ DataLayoutEntryAttr DataLayoutEntryAttr::parse(DialectAsmParser &parser) {
: 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<Type>())
os << type;
@@ -277,7 +277,7 @@ DataLayoutEntryListRef DataLayoutSpecAttr::getEntries() const {
/// 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 @@ DataLayoutSpecAttr DataLayoutSpecAttr::parse(DialectAsmParser &parser) {
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
index e0a5ab9449cfb..69feca96b84d2 100644
--- a/mlir/lib/Dialect/EmitC/IR/EmitC.cpp
+++ b/mlir/lib/Dialect/EmitC/IR/EmitC.cpp
@@ -166,7 +166,7 @@ static ParseResult parseIncludeOp(OpAsmParser &parser, OperationState &result) {
#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 @@ void EmitCDialect::printAttribute(Attribute attr, DialectAsmPrinter &os) const {
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 @@ void emitc::OpaqueAttr::print(DialectAsmPrinter &printer) const {
#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 @@ Type emitc::OpaqueType::parse(DialectAsmParser &parser) {
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
index b69988c8fea7f..ba7ec4f283af2 100644
--- a/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
+++ b/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
@@ -2425,7 +2425,7 @@ static constexpr const FastmathFlags fastmathFlagsList[] = {
// 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 @@ void FMFAttr::print(DialectAsmPrinter &printer) const {
printer << ">";
}
-Attribute FMFAttr::parse(DialectAsmParser &parser, Type type) {
+Attribute FMFAttr::parse(AsmParser &parser, Type type) {
if (failed(parser.parseLess()))
return {};
@@ -2463,7 +2463,7 @@ Attribute FMFAttr::parse(DialectAsmParser &parser, Type type) {
return FMFAttr::get(parser.getContext(), flags);
}
-void LinkageAttr::print(DialectAsmPrinter &printer) const {
+void LinkageAttr::print(AsmPrinter &printer) const {
printer << "<";
if (static_cast<uint64_t>(getLinkage()) <= getMaxEnumValForLinkage())
printer << stringifyEnum(getLinkage());
@@ -2472,7 +2472,7 @@ void LinkageAttr::print(DialectAsmPrinter &printer) const {
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 @@ LoopOptionsAttr LoopOptionsAttr::get(MLIRContext *context,
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 @@ void LoopOptionsAttr::print(DialectAsmPrinter &printer) const {
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
index 312f6867585b0..ca1bbbf59a694 100644
--- a/mlir/lib/Dialect/LLVMIR/IR/LLVMTypeSyntax.cpp
+++ b/mlir/lib/Dialect/LLVMIR/IR/LLVMTypeSyntax.cpp
@@ -23,7 +23,7 @@ using namespace mlir::LLVM;
/// 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<IntegerType, FloatType, VectorType>())
return mlir::LLVM::detail::printType(type, printer);
printer.printType(type);
@@ -51,14 +51,14 @@ static StringRef getTypeKeyword(Type type) {
/// 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<StringRef> knownStructNames;
unsigned stackSize = knownStructNames.size();
(void)stackSize;
@@ -101,15 +101,14 @@ static void printStructType(DialectAsmPrinter &printer, LLVMStructType type) {
/// Prints a type containing a fixed number of elements.
template <typename TypeTy>
-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 @@ static void printFunctionType(DialectAsmPrinter &printer,
/// struct<"c", (ptr<struct<"b", (ptr<struct<"c">>)>>,
/// ptr<struct<"b", (ptr<struct<"c">>)>>)>
/// 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 << "<<NULL-TYPE>>";
return;
@@ -173,11 +172,11 @@ void mlir::LLVM::detail::printType(Type type, DialectAsmPrinter &printer) {
// 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 @@ static LLVMFunctionType parseFunctionType(DialectAsmParser &parser) {
/// 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 @@ static LLVMPointerType parsePointerType(DialectAsmParser &parser) {
/// 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<int64_t, 2> dims;
llvm::SMLoc dimPos, typePos;
Type elementType;
@@ -270,7 +269,7 @@ static Type parseVectorType(DialectAsmParser &parser) {
/// Parses an LLVM dialect array type.
/// llvm-type ::= `array<` integer `x` llvm-type `>`
-static LLVMArrayType parseArrayType(DialectAsmParser &parser) {
+static LLVMArrayType parseArrayType(AsmParser &parser) {
SmallVector<int64_t, 1> dims;
llvm::SMLoc sizePos;
Type elementType;
@@ -292,7 +291,7 @@ static LLVMArrayType parseArrayType(DialectAsmParser &parser) {
/// error at `subtypesLoc` in case of failure.
static LLVMStructType trySetStructBody(LLVMStructType type,
ArrayRef<Type> subtypes, bool isPacked,
- DialectAsmParser &parser,
+ AsmParser &parser,
llvm::SMLoc subtypesLoc) {
for (Type t : subtypes) {
if (!LLVMStructType::isValidElementType(t)) {
@@ -315,14 +314,14 @@ static LLVMStructType trySetStructBody(LLVMStructType type,
/// `(` 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<StringRef> knownStructNames;
unsigned stackSize = knownStructNames.size();
(void)stackSize;
@@ -417,7 +416,7 @@ static LLVMStructType parseStructType(DialectAsmParser &parser) {
/// 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 @@ static Type dispatchParse(DialectAsmParser &parser, bool allowAny = true) {
}
/// 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
index 0e16d3e929e2a..2d357fa039fee 100644
--- a/mlir/lib/Dialect/PDL/IR/PDLTypes.cpp
+++ b/mlir/lib/Dialect/PDL/IR/PDLTypes.cpp
@@ -33,7 +33,7 @@ void PDLDialect::registerTypes() {
>();
}
-static Type parsePDLType(DialectAsmParser &parser) {
+static Type parsePDLType(AsmParser &parser) {
StringRef typeTag;
if (parser.parseKeyword(&typeTag))
return Type();
@@ -74,7 +74,7 @@ bool PDLType::classof(Type type) {
// RangeType
//===----------------------------------------------------------------------===//
-Type RangeType::parse(DialectAsmParser &parser) {
+Type RangeType::parse(AsmParser &parser) {
if (parser.parseLess())
return Type();
@@ -92,7 +92,7 @@ Type RangeType::parse(DialectAsmParser &parser) {
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
index 2d844bbf89bb4..bd8018155bf8a 100644
--- a/mlir/lib/Dialect/SparseTensor/IR/SparseTensorDialect.cpp
+++ b/mlir/lib/Dialect/SparseTensor/IR/SparseTensorDialect.cpp
@@ -39,7 +39,7 @@ static bool acceptBitWidth(unsigned bitWidth) {
}
}
-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 @@ Attribute SparseTensorEncodingAttr::parse(DialectAsmParser &parser, Type type) {
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
index 703bc9c6d5b6f..bba4e4f977633 100644
--- a/mlir/lib/Dialect/Vector/VectorOps.cpp
+++ b/mlir/lib/Dialect/Vector/VectorOps.cpp
@@ -169,7 +169,7 @@ static constexpr const CombiningKind combiningKindsList[] = {
// 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 @@ void CombiningKindAttr::print(DialectAsmPrinter &printer) const {
printer << ">";
}
-Attribute CombiningKindAttr::parse(DialectAsmParser &parser) {
+Attribute CombiningKindAttr::parse(AsmParser &parser, Type type) {
if (failed(parser.parseLess()))
return {};
@@ -207,7 +207,7 @@ Attribute VectorDialect::parseAttribute(DialectAsmParser &parser,
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
index 1246facc0be11..3a860994f0e84 100644
--- a/mlir/test/lib/Dialect/Test/TestAttributes.cpp
+++ b/mlir/test/lib/Dialect/Test/TestAttributes.cpp
@@ -29,15 +29,14 @@ using namespace test;
// 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 @@ void AttrWithSelfTypeParamAttr::print(DialectAsmPrinter &printer) const {
// 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 @@ void AttrWithTypeBuilderAttr::print(DialectAsmPrinter &printer) const {
// CompoundAAttr
//===----------------------------------------------------------------------===//
-Attribute CompoundAAttr::parse(DialectAsmParser &parser, Type type) {
+Attribute CompoundAAttr::parse(AsmParser &parser, Type type) {
int widthOfSomething;
Type oneType;
SmallVector<int, 4> arrayOfInts;
@@ -81,7 +80,7 @@ Attribute CompoundAAttr::parse(DialectAsmParser &parser, Type type) {
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 @@ void CompoundAAttr::print(DialectAsmPrinter &printer) const {
// CompoundAAttr
//===----------------------------------------------------------------------===//
-Attribute TestI64ElementsAttr::parse(DialectAsmParser &parser, Type type) {
+Attribute TestI64ElementsAttr::parse(AsmParser &parser, Type type) {
SmallVector<uint64_t> elements;
if (parser.parseLess() || parser.parseLSquare())
return Attribute();
@@ -108,7 +107,7 @@ Attribute TestI64ElementsAttr::parse(DialectAsmParser &parser, Type type) {
parser.getContext(), type.cast<ShapedType>(), elements);
}
-void TestI64ElementsAttr::print(DialectAsmPrinter &printer) const {
+void TestI64ElementsAttr::print(AsmPrinter &printer) const {
printer << "<[";
llvm::interleaveComma(getElements(), printer);
printer << "] : " << getType() << ">";
@@ -141,7 +140,7 @@ TestAttrWithFormatAttr::verify(function_ref<InFlightDiagnostic()> emitError,
// Utility Functions for Generated Attributes
//===----------------------------------------------------------------------===//
-static FailureOr<SmallVector<int>> parseIntArray(DialectAsmParser &parser) {
+static FailureOr<SmallVector<int>> parseIntArray(AsmParser &parser) {
SmallVector<int> ints;
if (parser.parseLSquare() || parser.parseCommaSeparatedList([&]() {
ints.push_back(0);
@@ -152,7 +151,7 @@ static FailureOr<SmallVector<int>> parseIntArray(DialectAsmParser &parser) {
return ints;
}
-static void printIntArray(DialectAsmPrinter &printer, ArrayRef<int> ints) {
+static void printIntArray(AsmPrinter &printer, ArrayRef<int> ints) {
printer << '[';
llvm::interleaveComma(ints, printer);
printer << ']';
@@ -162,7 +161,7 @@ static void printIntArray(DialectAsmPrinter &printer, ArrayRef<int> ints) {
// 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 @@ Attribute TestSubElementsAccessAttr::parse(::mlir::DialectAsmParser &parser,
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.cpp b/mlir/test/lib/Dialect/Test/TestTypes.cpp
index 28aafa4427b61..9b65f2fc06a37 100644
--- a/mlir/test/lib/Dialect/Test/TestTypes.cpp
+++ b/mlir/test/lib/Dialect/Test/TestTypes.cpp
@@ -26,7 +26,7 @@ using namespace test;
// 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 @@ parseSignedness(DialectAsmParser &parser,
}
// 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 @@ static llvm::hash_code test::hash_value(const FieldInfo &fi) { // NOLINT
// CompoundAType
//===----------------------------------------------------------------------===//
-Type CompoundAType::parse(DialectAsmParser &parser) {
+Type CompoundAType::parse(AsmParser &parser) {
int widthOfSomething;
Type oneType;
SmallVector<int, 4> arrayOfInts;
@@ -108,7 +108,7 @@ Type CompoundAType::parse(DialectAsmParser &parser) {
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 @@ void TestType::printTypeC(Location loc) const {
// 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 @@ void TestDialect::registerTypes() {
SimpleAType::attachInterface<PtrElementModel>(*getContext());
}
-static Type parseTestType(DialectAsmParser &parser, SetVector<Type> &stack) {
+static Type parseTestType(AsmParser &parser, SetVector<Type> &stack) {
StringRef typeTag;
if (failed(parser.parseKeyword(&typeTag)))
return Type();
@@ -281,7 +281,7 @@ Type TestDialect::parseType(DialectAsmParser &parser) const {
return parseTestType(parser, stack);
}
-static void printTestType(Type type, DialectAsmPrinter &printer,
+static void printTestType(Type type, AsmPrinter &printer,
SetVector<Type> &stack) {
if (succeeded(generatedTypePrinter(type, printer)))
return;
diff --git a/mlir/test/lib/Dialect/Test/TestTypes.h b/mlir/test/lib/Dialect/Test/TestTypes.h
index 7614ae401d1f0..22a18c5461d50 100644
--- a/mlir/test/lib/Dialect/Test/TestTypes.h
+++ b/mlir/test/lib/Dialect/Test/TestTypes.h
@@ -56,7 +56,7 @@ inline llvm::hash_code hash_value(const test::CustomParam ¶m) {
namespace mlir {
template <>
struct FieldParser<test::CustomParam> {
- static FailureOr<test::CustomParam> parse(DialectAsmParser &parser) {
+ static FailureOr<test::CustomParam> parse(AsmParser &parser) {
auto value = FieldParser<int>::parse(parser);
if (failed(value))
return failure();
@@ -65,8 +65,8 @@ struct FieldParser<test::CustomParam> {
};
} // 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/mlir-tblgen/attr-or-type-format.td b/mlir/test/mlir-tblgen/attr-or-type-format.td
index b52179051b4c7..96ec74141910d 100644
--- a/mlir/test/mlir-tblgen/attr-or-type-format.td
+++ b/mlir/test/mlir-tblgen/attr-or-type-format.td
@@ -34,7 +34,7 @@ def TypeParamB : TypeParameter<"TestParamD", "a type param D"> {
/// 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<IntegerAttr> _result_value;
// ATTR: FailureOr<TestParamA> _result_complex;
@@ -57,7 +57,7 @@ def TypeParamB : TypeParameter<"TestParamD", "a type param D"> {
// 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 @@ def AttrA : TestAttr<"TestA"> {
/// 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 @@ def AttrA : TestAttr<"TestA"> {
// 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 @@ def AttrB : TestAttr<"TestB"> {
/// 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<int> _result_v0;
// ATTR: ::mlir::FailureOr<int> _result_v1;
@@ -152,7 +152,7 @@ def AttrB : TestAttr<"TestB"> {
// 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 @@ def AttrC : TestAttr<"TestF"> {
/// 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<IntegerAttr> _result_value;
// TYPE: FailureOr<TestParamC> _result_complex;
// TYPE: if (parser.parseKeyword("foo"))
@@ -206,7 +206,7 @@ def AttrC : TestAttr<"TestF"> {
// 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 @@ def TypeA : TestType<"TestC"> {
/// 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 @@ def TypeA : TestType<"TestC"> {
// 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 @@ def TypeB : TestType<"TestD"> {
/// 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<IntegerAttr> _result_v0;
// TYPE: FailureOr<IntegerAttr> _result_v1;
// TYPE: FailureOr<IntegerAttr> _result_v2;
@@ -357,7 +357,7 @@ def TypeB : TestType<"TestD"> {
// 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
index cb0cc72e68227..64edaad23e4b0 100644
--- a/mlir/test/mlir-tblgen/attrdefs.td
+++ b/mlir/test/mlir-tblgen/attrdefs.td
@@ -19,7 +19,7 @@ include "mlir/IR/OpBase.td"
// 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 @@ def B_CompoundAttrA : TestAttr<"CompoundA"> {
// 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 @@ def C_IndexAttr : TestAttr<"Index"> {
// 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
index 766d93808b757..2c03695409d1b 100644
--- a/mlir/test/mlir-tblgen/typedefs.td
+++ b/mlir/test/mlir-tblgen/typedefs.td
@@ -7,8 +7,8 @@ include "mlir/IR/OpBase.td"
// 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 @@ include "mlir/IR/OpBase.td"
// 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 @@ def B_CompoundTypeA : TestType<"CompoundA"> {
// 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 @@ def C_IndexType : TestType<"Index"> {
// 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
index 1b6e9a4388493..f8fe56dc423e9 100644
--- a/mlir/tools/mlir-tblgen/AttrOrTypeDefGen.cpp
+++ b/mlir/tools/mlir-tblgen/AttrOrTypeDefGen.cpp
@@ -210,7 +210,9 @@ struct TypeDefGenerator : public DefGenerator {
/// later on.
static const char *const typeDefDeclHeader = R"(
namespace mlir {
+class AsmParser;
class DialectAsmParser;
+class AsmPrinter;
class DialectAsmPrinter;
} // namespace mlir
)";
@@ -256,8 +258,8 @@ static const char *const defDeclParametricBeginStr = R"(
/// {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 @@ void DefGenerator::emitTypeDefList(ArrayRef<AttrOrTypeDef> defs) {
/// {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 @@ void {0}::printType(::mlir::Type type,
/// {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 @@ void DefGenerator::emitParsePrint(const AttrOrTypeDef &def) {
// 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 @@ void DefGenerator::emitParsePrint(const AttrOrTypeDef &def) {
// 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
index 2dbc3712ccbfc..339fba7bedccd 100644
--- a/mlir/tools/mlir-tblgen/AttrOrTypeFormatGen.cpp
+++ b/mlir/tools/mlir-tblgen/AttrOrTypeFormatGen.cpp
@@ -162,7 +162,7 @@ class StructDirective
///
/// $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 @@ ::mlir::Attribute $0::parse(::mlir::DialectAsmParser &$_parser,
///
/// $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 @@ static const char *const parseErrorStr =
///
/// $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.
More information about the flang-commits
mailing list