diff --git a/mlir/include/mlir/Dialect/ArmSVE/ArmSVE.td b/mlir/include/mlir/Dialect/ArmSVE/ArmSVE.td --- a/mlir/include/mlir/Dialect/ArmSVE/ArmSVE.td +++ b/mlir/include/mlir/Dialect/ArmSVE/ArmSVE.td @@ -67,7 +67,7 @@ ); let printer = [{ - $_printer << "vector<"; + $_printer << "<"; for (int64_t dim : getShape()) $_printer << dim << 'x'; $_printer << getElementType() << '>'; 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 @@ -339,7 +339,6 @@ #include "mlir/Dialect/Async/IR/AsyncOpsTypes.cpp.inc" void ValueType::print(DialectAsmPrinter &printer) const { - printer << getMnemonic(); printer << "<"; printer.printType(getValueType()); printer << '>'; 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 @@ -201,7 +201,7 @@ } void emitc::OpaqueAttr::print(DialectAsmPrinter &printer) const { - printer << "opaque<\""; + printer << "<\""; llvm::printEscapedString(getValue(), printer.getStream()); printer << "\">"; } @@ -228,7 +228,7 @@ } void emitc::OpaqueType::print(DialectAsmPrinter &printer) const { - printer << "opaque<\""; + 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 @@ -2426,7 +2426,7 @@ }; void FMFAttr::print(DialectAsmPrinter &printer) const { - printer << "fastmath<"; + printer << "<"; auto flags = llvm::make_filter_range(fastmathFlagsList, [&](auto flag) { return bitEnumContains(this->getFlags(), flag); }); @@ -2464,7 +2464,7 @@ } void LinkageAttr::print(DialectAsmPrinter &printer) const { - printer << "linkage<"; + printer << "<"; if (static_cast(getLinkage()) <= getMaxEnumValForLinkage()) printer << stringifyEnum(getLinkage()); else @@ -2580,7 +2580,7 @@ } void LoopOptionsAttr::print(DialectAsmPrinter &printer) const { - printer << getMnemonic() << "<"; + printer << "<"; llvm::interleaveComma(getOptions(), printer, [&](auto option) { printer << stringifyEnum(option.first) << " = "; switch (option.first) { 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 @@ -93,7 +93,7 @@ } void RangeType::print(DialectAsmPrinter &printer) const { - printer << "range<"; + 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 @@ -119,7 +119,7 @@ void SparseTensorEncodingAttr::print(DialectAsmPrinter &printer) const { // Print the struct-like storage in dictionary fashion. - printer << "encoding<{ dimLevelType = [ "; + printer << "<{ dimLevelType = [ "; for (unsigned i = 0, e = getDimLevelType().size(); i < e; i++) { switch (getDimLevelType()[i]) { case DimLevelType::Dense: 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 @@ -38,7 +38,7 @@ } void AttrWithSelfTypeParamAttr::print(DialectAsmPrinter &printer) const { - printer << "attr_with_self_type_param " << getType(); + printer << " " << getType(); } //===----------------------------------------------------------------------===// @@ -53,7 +53,7 @@ } void AttrWithTypeBuilderAttr::print(DialectAsmPrinter &printer) const { - printer << "attr_with_type_builder " << getAttr(); + printer << " " << getAttr(); } //===----------------------------------------------------------------------===// @@ -82,8 +82,7 @@ } void CompoundAAttr::print(DialectAsmPrinter &printer) const { - printer << "cmpnd_a<" << getWidthOfSomething() << ", " << getOneType() - << ", ["; + printer << "<" << getWidthOfSomething() << ", " << getOneType() << ", ["; llvm::interleaveComma(getArrayOfInts(), printer); printer << "]>"; } @@ -110,7 +109,7 @@ } void TestI64ElementsAttr::print(DialectAsmPrinter &printer) const { - printer << "i64_elements<["; + printer << "<["; llvm::interleaveComma(getElements(), printer); printer << "] : " << getType() << ">"; } @@ -177,8 +176,8 @@ void TestSubElementsAccessAttr::print( ::mlir::DialectAsmPrinter &printer) const { - printer << getMnemonic() << "<" << getFirst() << ", " << getSecond() << ", " - << getThird() << ">"; + printer << "<" << getFirst() << ", " << getSecond() << ", " << getThird() + << ">"; } void TestSubElementsAccessAttr::walkImmediateSubElements( diff --git a/mlir/test/lib/Dialect/Test/TestTypeDefs.td b/mlir/test/lib/Dialect/Test/TestTypeDefs.td --- a/mlir/test/lib/Dialect/Test/TestTypeDefs.td +++ b/mlir/test/lib/Dialect/Test/TestTypeDefs.td @@ -62,7 +62,7 @@ // We define the printer inline. let printer = [{ - $_printer << "int<"; + $_printer << "<"; printSignedness($_printer, getImpl()->signedness); $_printer << ", " << getImpl()->width << ">"; }]; @@ -122,7 +122,7 @@ // Prints the type in this format: // struct<[{field1Name, field1Type}, {field2Name, field2Type}] let printer = [{ - $_printer << "struct" << "<"; + $_printer << "<"; for (size_t i=0, e = getImpl()->fields.size(); i < e; i++) { const auto& field = getImpl()->fields[i]; $_printer << "{" << field.name << "," << field.type << "}"; 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 @@ -109,8 +109,7 @@ return get(parser.getContext(), widthOfSomething, oneType, arrayOfInts); } void CompoundAType::print(DialectAsmPrinter &printer) const { - printer << "cmpnd_a<" << getWidthOfSomething() << ", " << getOneType() - << ", ["; + printer << "<" << getWidthOfSomething() << ", " << getOneType() << ", ["; auto intArray = getArrayOfInts(); llvm::interleaveComma(intArray, printer); printer << "]>"; @@ -150,7 +149,7 @@ } void TestTypeWithLayoutType::print(DialectAsmPrinter &printer) const { - printer << "test_type_with_layout<" << getKey() << ">"; + printer << "<" << getKey() << ">"; } unsigned 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 @@ -1007,13 +1007,11 @@ os << formatv(" .Case<{0}::{1}>([&]({0}::{1} t) {{\n ", cppNamespace, cppClassName); + os << formatv("printer << {0}::{1}::getMnemonic();", cppNamespace, + cppClassName); // If the def has no parameters and no printer, just print the mnemonic. - if (def.getNumParameters() == 0 && !def.getPrinterCode()) { - os << formatv("printer << {0}::{1}::getMnemonic();", cppNamespace, - cppClassName); - } else { + if (def.getNumParameters() != 0 || def.getPrinterCode()) os << "t.print(printer);"; - } os << "\n return ::mlir::success();\n })\n"; } os << llvm::formatv(