Skip to content

Commit 4a25ae2

Browse files
committed
fix: remove unnecessary printQualifiedAttrOrType function
This commit removes `printQualifiedAttrOrType` function, since printing already ignores the mnemonic of the nested attribute.
1 parent 8ee2f6f commit 4a25ae2

File tree

2 files changed

+1
-54
lines changed

2 files changed

+1
-54
lines changed

mlir/include/mlir/IR/OpImplementation.h

Lines changed: 0 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
#include "llvm/ADT/Twine.h"
2121
#include "llvm/Support/SMLoc.h"
2222
#include <optional>
23-
#include <type_traits>
2423

2524
namespace {
2625
// reference https://stackoverflow.com/a/16000226
@@ -204,57 +203,6 @@ class AsmPrinter {
204203
*this << attrOrType;
205204
}
206205

207-
/// Print the provided attribute or type ensuring that any dialect-specific
208-
/// prefixes (e.g. `#dialect.mnemonic`) are retained. This is used in
209-
/// contexts, such as structured property dictionaries, where the fully
210-
/// qualified form is required for disambiguation.
211-
template <typename AttrOrType,
212-
std::enable_if_t<std::is_convertible_v<AttrOrType, Attribute>> *
213-
sfinae = nullptr>
214-
void printQualifiedAttrOrType(AttrOrType attrOrType) {
215-
Attribute attr = attrOrType;
216-
Dialect &dialect = attr.getDialect();
217-
StringRef dialectNamespace = dialect.getNamespace();
218-
if (dialectNamespace.empty() || dialectNamespace == "builtin") {
219-
printStrippedAttrOrType(attrOrType);
220-
return;
221-
}
222-
printAttribute(attr);
223-
}
224-
225-
template <typename AttrOrType,
226-
std::enable_if_t<std::is_convertible_v<AttrOrType, Type> &&
227-
!std::is_convertible_v<AttrOrType, Attribute>> *
228-
sfinae = nullptr>
229-
void printQualifiedAttrOrType(AttrOrType attrOrType) {
230-
Type type = attrOrType;
231-
Dialect &dialect = type.getDialect();
232-
StringRef dialectNamespace = dialect.getNamespace();
233-
if (dialectNamespace.empty() || dialectNamespace == "builtin") {
234-
printStrippedAttrOrType(attrOrType);
235-
return;
236-
}
237-
printType(type);
238-
}
239-
240-
template <typename ElementT,
241-
std::enable_if_t<std::is_convertible_v<ElementT, Attribute> ||
242-
std::is_convertible_v<ElementT, Type>> *sfinae =
243-
nullptr>
244-
void printQualifiedAttrOrType(ArrayRef<ElementT> attrOrTypes) {
245-
llvm::interleaveComma(attrOrTypes, getStream(), [&](ElementT element) {
246-
printQualifiedAttrOrType(element);
247-
});
248-
}
249-
250-
template <typename AttrOrType,
251-
std::enable_if_t<!std::is_convertible_v<AttrOrType, Attribute> &&
252-
!std::is_convertible_v<AttrOrType, Type>> *
253-
sfinae = nullptr>
254-
void printQualifiedAttrOrType(AttrOrType attrOrType) {
255-
*this << attrOrType;
256-
}
257-
258206
/// Print the given attribute without its type. The corresponding parser must
259207
/// provide a valid type for the attribute.
260208
virtual void printAttributeWithoutType(Attribute attr);

mlir/tools/mlir-tblgen/AttrOrTypeFormatGen.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,7 @@ static const char *const defaultParameterPrinter =
174174

175175
/// Qualified printer for attribute or type parameters: it does not elide
176176
/// dialect and mnemonic.
177-
static const char *const qualifiedParameterPrinter =
178-
"$_printer.printQualifiedAttrOrType($_self)";
177+
static const char *const qualifiedParameterPrinter = "$_printer << $_self";
179178

180179
/// Print an error when failing to parse an element.
181180
///

0 commit comments

Comments
 (0)