[Mlir-commits] [mlir] [mlir][LLVMIR][NFC] Migrate to OpAsmAttrInterface for ASM alias generation (PR #130479)
Hongren Zheng
llvmlistbot at llvm.org
Fri Apr 11 07:10:23 PDT 2025
https://github.com/ZenithalHourlyRate updated https://github.com/llvm/llvm-project/pull/130479
>From 9e32afec73309133cc1278d58bd4959bb2ee3ef7 Mon Sep 17 00:00:00 2001
From: Zenithal <i at zenithal.me>
Date: Sun, 16 Mar 2025 06:44:20 +0000
Subject: [PATCH 1/2] [MLIR][TableGen] Add genMnemonicAlias field for
OpAsm{Type,Attr}Interface
---
.../DefiningDialects/AttributesAndTypes.md | 14 ++++++
mlir/include/mlir/IR/AttrTypeBase.td | 3 ++
mlir/include/mlir/TableGen/AttrOrTypeDef.h | 4 ++
mlir/lib/TableGen/AttrOrTypeDef.cpp | 4 ++
mlir/test/mlir-tblgen/attrdefs.td | 14 ++++++
mlir/tools/mlir-tblgen/AttrOrTypeDefGen.cpp | 48 +++++++++++++++++--
6 files changed, 82 insertions(+), 5 deletions(-)
diff --git a/mlir/docs/DefiningDialects/AttributesAndTypes.md b/mlir/docs/DefiningDialects/AttributesAndTypes.md
index 44be4c8ed3dcc..3612d4dc9d051 100644
--- a/mlir/docs/DefiningDialects/AttributesAndTypes.md
+++ b/mlir/docs/DefiningDialects/AttributesAndTypes.md
@@ -105,6 +105,9 @@ def My_IntegerType : MyDialect_Type<"Integer", "int"> {
/// Indicate that our type will add additional verification to the parameters.
let genVerifyDecl = 1;
+
+ /// Indicate that our type will use the mnemonic as alias in assembly.
+ let genMnemonicAlias = 1;
}
```
@@ -160,6 +163,9 @@ def My_IntegerAttr : MyDialect_Attr<"Integer", "int"> {
/// Indicate to the ODS generator that we do not want the default builders,
/// as we have defined our own simpler ones.
let skipDefaultBuilders = 1;
+
+ /// Indicate that our attribute will use the mnemonic as alias in assembly.
+ let genMnemonicAlias = 1;
}
```
@@ -1182,6 +1188,14 @@ Note that these are mechanisms intended for long-tail cases by power users; for
not-yet-implemented widely-applicable cases, improving the infrastructure is
preferable.
+### Mnemonic Alias in Assembly
+
+Attribute and Type might want to use aliases in the assembly to reduce verbosity.
+In such cases, `OpAsmAttrInterface` and `OpAsmTypeInterface` could be used to
+generate aliases. In many cases, a simple mnemonic alias is enough, then
+`genMnemonicAlias` could be turned on to automatically generate
+an `getAlias` implementation using the `mnemonic` of the Attribute or Type.
+
### Registering with the Dialect
Once the attributes and types have been defined, they must then be registered
diff --git a/mlir/include/mlir/IR/AttrTypeBase.td b/mlir/include/mlir/IR/AttrTypeBase.td
index 38d38cf098df3..7ea82879bfdcd 100644
--- a/mlir/include/mlir/IR/AttrTypeBase.td
+++ b/mlir/include/mlir/IR/AttrTypeBase.td
@@ -249,6 +249,9 @@ class AttrOrTypeDef<string valueType, string name, list<Trait> defTraits,
// generated code is placed inside the class's C++ namespace. `$cppClass` is
// replaced by the class name.
code extraClassDefinition = [{}];
+
+ // Generate a default 'getAlias' method for OpAsm{Type,Attr}Interface.
+ bit genMnemonicAlias = 0;
}
// Define a new attribute, named `name`, belonging to `dialect` that inherits
diff --git a/mlir/include/mlir/TableGen/AttrOrTypeDef.h b/mlir/include/mlir/TableGen/AttrOrTypeDef.h
index c3d730e42ef70..dd811557c065e 100644
--- a/mlir/include/mlir/TableGen/AttrOrTypeDef.h
+++ b/mlir/include/mlir/TableGen/AttrOrTypeDef.h
@@ -212,6 +212,10 @@ class AttrOrTypeDef {
/// Returns the def's extra class definition code.
std::optional<StringRef> getExtraDefs() const;
+ /// Returns true if we need to generate a default 'getAlias' implementation
+ /// using the mnemonic.
+ bool genMnemonicAlias() const;
+
/// Get the code location (for error printing).
ArrayRef<SMLoc> getLoc() const;
diff --git a/mlir/lib/TableGen/AttrOrTypeDef.cpp b/mlir/lib/TableGen/AttrOrTypeDef.cpp
index 9e8f789d71b5e..5f77e413c9368 100644
--- a/mlir/lib/TableGen/AttrOrTypeDef.cpp
+++ b/mlir/lib/TableGen/AttrOrTypeDef.cpp
@@ -205,6 +205,10 @@ std::optional<StringRef> AttrOrTypeDef::getExtraDefs() const {
return value.empty() ? std::optional<StringRef>() : value;
}
+bool AttrOrTypeDef::genMnemonicAlias() const {
+ return def->getValueAsBit("genMnemonicAlias");
+}
+
ArrayRef<SMLoc> AttrOrTypeDef::getLoc() const { return def->getLoc(); }
bool AttrOrTypeDef::skipDefaultBuilders() const {
diff --git a/mlir/test/mlir-tblgen/attrdefs.td b/mlir/test/mlir-tblgen/attrdefs.td
index 35d2c49619ee6..adec90dc5a371 100644
--- a/mlir/test/mlir-tblgen/attrdefs.td
+++ b/mlir/test/mlir-tblgen/attrdefs.td
@@ -172,3 +172,17 @@ def H_TestExtraClassAttr : TestAttr<"TestExtraClass"> {
// DEF-LABEL: int TestExtraClassAttr::getFoo(int i) {
// DEF: return i+1;
// DEF-NEXT: }
+
+def I_TestGenMnemonicAliasAttr : TestAttr<"TestGenMnemonicAlias"> {
+ let mnemonic = "test_gen_mnemonic_alias";
+ let genMnemonicAlias = 1;
+}
+
+// DECL-LABEL: class TestGenMnemonicAliasAttr : public ::mlir::Attribute
+// DECL-SAME: ::mlir::OpAsmAttrInterface::Trait
+// DECL: ::mlir::OpAsmAliasResult getAlias(::llvm::raw_ostream &os) const;
+
+// DEF-LABEL: ::mlir::OpAsmAliasResult TestGenMnemonicAliasAttr::getAlias(::llvm::raw_ostream &os) const {
+// DEF-NEXT: os << "test_gen_mnemonic_alias";
+// DEF-NEXT: return ::mlir::OpAsmAliasResult::OverridableAlias;
+// DEF-NEXT: }
diff --git a/mlir/tools/mlir-tblgen/AttrOrTypeDefGen.cpp b/mlir/tools/mlir-tblgen/AttrOrTypeDefGen.cpp
index cf0d827942949..a5df8a69463fe 100644
--- a/mlir/tools/mlir-tblgen/AttrOrTypeDefGen.cpp
+++ b/mlir/tools/mlir-tblgen/AttrOrTypeDefGen.cpp
@@ -130,6 +130,12 @@ class DefGen {
/// Emit a trait method.
void emitTraitMethod(const InterfaceMethod &method);
+ //===--------------------------------------------------------------------===//
+ // OpAsm{Type,Attr}Interface Default Method Emission
+
+ /// Emit 'getAlias' method using mnemonic as alias.
+ void emitMnemonicAliasMethod();
+
//===--------------------------------------------------------------------===//
// Storage Class Emission
void emitStorageClass();
@@ -215,6 +221,9 @@ DefGen::DefGen(const AttrOrTypeDef &def)
emitAccessors();
// Emit trait interface methods
emitInterfaceMethods();
+ // Emit OpAsm{Type,Attr}Interface default methods
+ if (def.genMnemonicAlias())
+ emitMnemonicAliasMethod();
defCls.finalize();
// Emit a storage class if one is needed
if (storageCls && def.genStorageClass())
@@ -229,11 +238,24 @@ void DefGen::createParentWithTraits() {
? strfmt("{0}::{1}", def.getStorageNamespace(),
def.getStorageClassName())
: strfmt("::mlir::{0}Storage", valueType));
- for (auto &trait : def.getTraits()) {
- defParent.addTemplateParam(
- isa<NativeTrait>(&trait)
- ? cast<NativeTrait>(&trait)->getFullyQualifiedTraitName()
- : cast<InterfaceTrait>(&trait)->getFullyQualifiedTraitName());
+ SmallVector<std::string> traitNames =
+ llvm::to_vector(llvm::map_range(def.getTraits(), [](auto &trait) {
+ return isa<NativeTrait>(&trait)
+ ? cast<NativeTrait>(&trait)->getFullyQualifiedTraitName()
+ : cast<InterfaceTrait>(&trait)->getFullyQualifiedTraitName();
+ }));
+ llvm::for_each(traitNames, [&](auto &traitName) {
+ defParent.addTemplateParam(traitName);
+ });
+
+ // Add OpAsmInterface::Trait if we automatically generate mnemonic alias
+ // method.
+ std::string opAsmInterfaceTraitName =
+ strfmt("::mlir::OpAsm{0}Interface::Trait", defType);
+ if (def.genMnemonicAlias() && llvm::none_of(traitNames, [&](auto &traitName) {
+ return traitName == opAsmInterfaceTraitName;
+ })) {
+ defParent.addTemplateParam(opAsmInterfaceTraitName);
}
defCls.addParent(std::move(defParent));
}
@@ -577,6 +599,22 @@ void DefGen::emitTraitMethod(const InterfaceMethod &method) {
std::move(params));
}
+//===----------------------------------------------------------------------===//
+// OpAsm{Type,Attr}Interface Default Method Emission
+
+void DefGen::emitMnemonicAliasMethod() {
+ // If the mnemonic is not set, there is nothing to do.
+ if (!def.getMnemonic())
+ return;
+
+ // Emit the mnemonic alias method.
+ SmallVector<MethodParameter> params{{"::llvm::raw_ostream &", "os"}};
+ Method *m = defCls.addMethod<Method::Const>("::mlir::OpAsmAliasResult",
+ "getAlias", std::move(params));
+ m->body().indent() << strfmt("os << \"{0}\";\n", *def.getMnemonic())
+ << "return ::mlir::OpAsmAliasResult::OverridableAlias;\n";
+}
+
//===----------------------------------------------------------------------===//
// Storage Class Emission
//===----------------------------------------------------------------------===//
>From ffd35faed17f4aa61345a2296b14cdf1de237528 Mon Sep 17 00:00:00 2001
From: Zenithal <i at zenithal.me>
Date: Sun, 9 Mar 2025 10:18:06 +0000
Subject: [PATCH 2/2] [mlir][LLVMIR][NFC] Migrate to OpAsmAttrInterface for ASM
alias generation
---
.../mlir/Dialect/LLVMIR/LLVMAttrDefs.td | 105 ++++++++++++++++++
mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp | 33 ------
2 files changed, 105 insertions(+), 33 deletions(-)
diff --git a/mlir/include/mlir/Dialect/LLVMIR/LLVMAttrDefs.td b/mlir/include/mlir/Dialect/LLVMIR/LLVMAttrDefs.td
index 690243525ede4..59cd081f80379 100644
--- a/mlir/include/mlir/Dialect/LLVMIR/LLVMAttrDefs.td
+++ b/mlir/include/mlir/Dialect/LLVMIR/LLVMAttrDefs.td
@@ -79,6 +79,9 @@ def LoopVectorizeAttr : LLVM_Attr<"LoopVectorize", "loop_vectorize"> {
);
let assemblyFormat = "`<` struct(params) `>`";
+
+ // Generate mnemonic alias for the attribute.
+ let genMnemonicAlias = 1;
}
def LoopInterleaveAttr : LLVM_Attr<"LoopInterleave", "loop_interleave"> {
@@ -92,6 +95,9 @@ def LoopInterleaveAttr : LLVM_Attr<"LoopInterleave", "loop_interleave"> {
);
let assemblyFormat = "`<` struct(params) `>`";
+
+ // Generate mnemonic alias for the attribute.
+ let genMnemonicAlias = 1;
}
def LoopUnrollAttr : LLVM_Attr<"LoopUnroll", "loop_unroll"> {
@@ -111,6 +117,9 @@ def LoopUnrollAttr : LLVM_Attr<"LoopUnroll", "loop_unroll"> {
);
let assemblyFormat = "`<` struct(params) `>`";
+
+ // Generate mnemonic alias for the attribute.
+ let genMnemonicAlias = 1;
}
def LoopUnrollAndJamAttr : LLVM_Attr<"LoopUnrollAndJam", "loop_unroll_and_jam"> {
@@ -130,6 +139,9 @@ def LoopUnrollAndJamAttr : LLVM_Attr<"LoopUnrollAndJam", "loop_unroll_and_jam">
);
let assemblyFormat = "`<` struct(params) `>`";
+
+ // Generate mnemonic alias for the attribute.
+ let genMnemonicAlias = 1;
}
def LoopLICMAttr : LLVM_Attr<"LoopLICM", "loop_licm"> {
@@ -145,6 +157,9 @@ def LoopLICMAttr : LLVM_Attr<"LoopLICM", "loop_licm"> {
);
let assemblyFormat = "`<` struct(params) `>`";
+
+ // Generate mnemonic alias for the attribute.
+ let genMnemonicAlias = 1;
}
def LoopDistributeAttr : LLVM_Attr<"LoopDistribute", "loop_distribute"> {
@@ -162,6 +177,9 @@ def LoopDistributeAttr : LLVM_Attr<"LoopDistribute", "loop_distribute"> {
);
let assemblyFormat = "`<` struct(params) `>`";
+
+ // Generate mnemonic alias for the attribute.
+ let genMnemonicAlias = 1;
}
def LoopPipelineAttr : LLVM_Attr<"LoopPipeline", "loop_pipeline"> {
@@ -176,6 +194,9 @@ def LoopPipelineAttr : LLVM_Attr<"LoopPipeline", "loop_pipeline"> {
);
let assemblyFormat = "`<` struct(params) `>`";
+
+ // Generate mnemonic alias for the attribute.
+ let genMnemonicAlias = 1;
}
def LoopPeeledAttr : LLVM_Attr<"LoopPeeled", "loop_peeled"> {
@@ -189,6 +210,9 @@ def LoopPeeledAttr : LLVM_Attr<"LoopPeeled", "loop_peeled"> {
);
let assemblyFormat = "`<` struct(params) `>`";
+
+ // Generate mnemonic alias for the attribute.
+ let genMnemonicAlias = 1;
}
def LoopUnswitchAttr : LLVM_Attr<"LoopUnswitch", "loop_unswitch"> {
@@ -202,6 +226,9 @@ def LoopUnswitchAttr : LLVM_Attr<"LoopUnswitch", "loop_unswitch"> {
);
let assemblyFormat = "`<` struct(params) `>`";
+
+ // Generate mnemonic alias for the attribute.
+ let genMnemonicAlias = 1;
}
def LoopAnnotationAttr : LLVM_Attr<"LoopAnnotation", "loop_annotation"> {
@@ -232,6 +259,9 @@ def LoopAnnotationAttr : LLVM_Attr<"LoopAnnotation", "loop_annotation"> {
);
let assemblyFormat = "`<` struct(params) `>`";
+
+ // Generate mnemonic alias for the attribute.
+ let genMnemonicAlias = 1;
}
//===----------------------------------------------------------------------===//
@@ -311,6 +341,9 @@ def LLVM_DIExpressionAttr : LLVM_Attr<"DIExpression", "di_expression"> {
def LLVM_DINullTypeAttr : LLVM_Attr<"DINullType", "di_null_type",
/*traits=*/[], "DITypeAttr"> {
let parameters = (ins);
+
+ // Generate mnemonic alias for the attribute.
+ let genMnemonicAlias = 1;
}
//===----------------------------------------------------------------------===//
@@ -336,6 +369,9 @@ def LLVM_DIBasicTypeAttr : LLVM_Attr<"DIBasicType", "di_basic_type",
}]>
];
let assemblyFormat = "`<` struct(params) `>`";
+
+ // Generate mnemonic alias for the attribute.
+ let genMnemonicAlias = 1;
}
//===----------------------------------------------------------------------===//
@@ -365,6 +401,9 @@ def LLVM_DICompileUnitAttr : LLVM_Attr<"DICompileUnit", "di_compile_unit",
}]>
];
let assemblyFormat = "`<` struct(params) `>`";
+
+ // Generate mnemonic alias for the attribute.
+ let genMnemonicAlias = 1;
}
//===----------------------------------------------------------------------===//
@@ -422,6 +461,9 @@ def LLVM_DICompositeTypeAttr : LLVM_Attr<"DICompositeType", "di_composite_type",
/// @}
}];
+
+ // Generate mnemonic alias for the attribute.
+ let genMnemonicAlias = 1;
}
//===----------------------------------------------------------------------===//
@@ -441,6 +483,9 @@ def LLVM_DIDerivedTypeAttr : LLVM_Attr<"DIDerivedType", "di_derived_type",
OptionalParameter<"DINodeAttr">:$extraData
);
let assemblyFormat = "`<` struct(params) `>`";
+
+ // Generate mnemonic alias for the attribute.
+ let genMnemonicAlias = 1;
}
//===----------------------------------------------------------------------===//
@@ -455,6 +500,9 @@ def LLVM_DIFileAttr : LLVM_Attr<"DIFile", "di_file", /*traits=*/[], "DIScopeAttr
}]>
];
let assemblyFormat = "`<` $name `in` $directory `>`";
+
+ // Generate mnemonic alias for the attribute.
+ let genMnemonicAlias = 1;
}
//===----------------------------------------------------------------------===//
@@ -469,6 +517,9 @@ def LLVM_DIGlobalVariableExpressionAttr
);
let assemblyFormat = "`<` struct(params) `>`";
let constBuilderCall = "$0";
+
+ // Generate mnemonic alias for the attribute.
+ let genMnemonicAlias = 1;
}
def DIGlobalVariableExpressionArrayAttr :
@@ -492,6 +543,9 @@ def LLVM_DIGlobalVariable : LLVM_Attr<"DIGlobalVariable", "di_global_variable",
OptionalParameter<"bool">:$isDefined,
OptionalParameter<"unsigned">:$alignInBits);
let assemblyFormat = "`<` struct(params) `>`";
+
+ // Generate mnemonic alias for the attribute.
+ let genMnemonicAlias = 1;
}
//===----------------------------------------------------------------------===//
@@ -515,6 +569,9 @@ def LLVM_DILexicalBlockAttr : LLVM_Attr<"DILexicalBlock", "di_lexical_block",
}]>
];
let assemblyFormat = "`<` struct(params) `>`";
+
+ // Generate mnemonic alias for the attribute.
+ let genMnemonicAlias = 1;
}
//===----------------------------------------------------------------------===//
@@ -536,6 +593,9 @@ def LLVM_DILexicalBlockFile : LLVM_Attr<"DILexicalBlockFile", "di_lexical_block_
}]>
];
let assemblyFormat = "`<` struct(params) `>`";
+
+ // Generate mnemonic alias for the attribute.
+ let genMnemonicAlias = 1;
}
//===----------------------------------------------------------------------===//
@@ -566,6 +626,9 @@ def LLVM_DILocalVariableAttr : LLVM_Attr<"DILocalVariable", "di_local_variable",
}]>
];
let assemblyFormat = "`<` struct(params) `>`";
+
+ // Generate mnemonic alias for the attribute.
+ let genMnemonicAlias = 1;
}
//===----------------------------------------------------------------------===//
@@ -619,6 +682,9 @@ def LLVM_DISubprogramAttr : LLVM_Attr<"DISubprogram", "di_subprogram",
/// @}
}];
+
+ // Generate mnemonic alias for the attribute.
+ let genMnemonicAlias = 1;
}
//===----------------------------------------------------------------------===//
@@ -639,6 +705,9 @@ def LLVM_DIModuleAttr : LLVM_Attr<"DIModule", "di_module",
);
let assemblyFormat = "`<` struct(params) `>`";
+
+ // Generate mnemonic alias for the attribute.
+ let genMnemonicAlias = 1;
}
//===----------------------------------------------------------------------===//
@@ -654,6 +723,9 @@ def LLVM_DINamespaceAttr : LLVM_Attr<"DINamespace", "di_namespace",
);
let assemblyFormat = "`<` struct(params) `>`";
+
+ // Generate mnemonic alias for the attribute.
+ let genMnemonicAlias = 1;
}
//===----------------------------------------------------------------------===//
@@ -673,6 +745,9 @@ def LLVM_DIImportedEntityAttr : LLVM_Attr<"DIImportedEntity", "di_imported_entit
);
let assemblyFormat = "`<` struct(params) `>`";
+
+ // Generate mnemonic alias for the attribute.
+ let genMnemonicAlias = 1;
}
//===----------------------------------------------------------------------===//
@@ -719,6 +794,9 @@ def LLVM_DICommonBlockAttr : LLVM_Attr<"DICommonBlock", "di_common_block",
OptionalParameter<"unsigned">:$line
);
let assemblyFormat = "`<` struct(params) `>`";
+
+ // Generate mnemonic alias for the attribute.
+ let genMnemonicAlias = 1;
}
//===----------------------------------------------------------------------===//
@@ -753,6 +831,9 @@ def LLVM_DISubroutineTypeAttr : LLVM_Attr<"DISubroutineType", "di_subroutine_typ
}]>
];
let assemblyFormat = "`<` struct(params) `>`";
+
+ // Generate mnemonic alias for the attribute.
+ let genMnemonicAlias = 1;
}
//===----------------------------------------------------------------------===//
@@ -778,6 +859,9 @@ def LLVM_DILabelAttr : LLVM_Attr<"DILabel", "di_label",
];
let assemblyFormat = "`<` struct(params) `>`";
+
+ // Generate mnemonic alias for the attribute.
+ let genMnemonicAlias = 1;
}
//===----------------------------------------------------------------------===//
@@ -797,6 +881,9 @@ def LLVM_DIStringTypeAttr : LLVM_Attr<"DIStringType", "di_string_type",
LLVM_DIEncodingParameter:$encoding
);
let assemblyFormat = "`<` struct(params) `>`";
+
+ // Generate mnemonic alias for the attribute.
+ let genMnemonicAlias = 1;
}
//===----------------------------------------------------------------------===//
@@ -845,6 +932,9 @@ def LLVM_AliasScopeDomainAttr : LLVM_Attr<"AliasScopeDomain",
}];
let assemblyFormat = "`<` struct(params) `>`";
+
+ // Generate mnemonic alias for the attribute.
+ let genMnemonicAlias = 1;
}
//===----------------------------------------------------------------------===//
@@ -902,6 +992,9 @@ def LLVM_AliasScopeAttr : LLVM_Attr<"AliasScope", "alias_scope"> {
let assemblyFormat = "`<` struct(params) `>`";
let genVerifyDecl = 1;
+
+ // Generate mnemonic alias for the attribute.
+ let genMnemonicAlias = 1;
}
def LLVM_AliasScopeArrayAttr
@@ -937,6 +1030,9 @@ def LLVM_AccessGroupAttr : LLVM_Attr<"AccessGroup", "access_group"> {
}];
let assemblyFormat = "`<` struct(params) `>`";
+
+ // Generate mnemonic alias for the attribute.
+ let genMnemonicAlias = 1;
}
def LLVM_AccessGroupArrayAttr
@@ -967,6 +1063,9 @@ def LLVM_TBAARootAttr : LLVM_Attr<"TBAARoot", "tbaa_root", [], "TBAANodeAttr"> {
}];
let assemblyFormat = "(`<` struct(params)^ `>`)?";
+
+ // Generate mnemonic alias for the attribute.
+ let genMnemonicAlias = 1;
}
//===----------------------------------------------------------------------===//
@@ -1040,6 +1139,9 @@ def LLVM_TBAATypeDescriptorAttr : LLVM_Attr<"TBAATypeDescriptor",
}];
let assemblyFormat = "`<` struct(params) `>`";
+
+ // Generate mnemonic alias for the attribute.
+ let genMnemonicAlias = 1;
}
//===----------------------------------------------------------------------===//
@@ -1082,6 +1184,9 @@ def LLVM_TBAATagAttr : LLVM_Attr<"TBAATag", "tbaa_tag"> {
}];
let assemblyFormat = "`<` struct(params) `>`";
+
+ // Generate mnemonic alias for the attribute.
+ let genMnemonicAlias = 1;
}
def LLVM_TBAATagArrayAttr
diff --git a/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp b/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
index 28d2019b225c5..3be7774b9d7a8 100644
--- a/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
+++ b/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
@@ -3765,36 +3765,6 @@ void CallIntrinsicOp::print(OpAsmPrinter &p) {
/*isVariadic=*/false, getResultTypes(), getResAttrsAttr());
}
-//===----------------------------------------------------------------------===//
-// OpAsmDialectInterface
-//===----------------------------------------------------------------------===//
-
-namespace {
-struct LLVMOpAsmDialectInterface : public OpAsmDialectInterface {
- using OpAsmDialectInterface::OpAsmDialectInterface;
-
- AliasResult getAlias(Attribute attr, raw_ostream &os) const override {
- return TypeSwitch<Attribute, AliasResult>(attr)
- .Case<AccessGroupAttr, AliasScopeAttr, AliasScopeDomainAttr,
- DIBasicTypeAttr, DICommonBlockAttr, DICompileUnitAttr,
- DICompositeTypeAttr, DIDerivedTypeAttr, DIFileAttr,
- DIGlobalVariableAttr, DIGlobalVariableExpressionAttr,
- DIImportedEntityAttr, DILabelAttr, DILexicalBlockAttr,
- DILexicalBlockFileAttr, DILocalVariableAttr, DIModuleAttr,
- DINamespaceAttr, DINullTypeAttr, DIStringTypeAttr,
- DISubprogramAttr, DISubroutineTypeAttr, LoopAnnotationAttr,
- LoopVectorizeAttr, LoopInterleaveAttr, LoopUnrollAttr,
- LoopUnrollAndJamAttr, LoopLICMAttr, LoopDistributeAttr,
- LoopPipelineAttr, LoopPeeledAttr, LoopUnswitchAttr, TBAARootAttr,
- TBAATagAttr, TBAATypeDescriptorAttr>([&](auto attr) {
- os << decltype(attr)::getMnemonic();
- return AliasResult::OverridableAlias;
- })
- .Default([](Attribute) { return AliasResult::NoAlias; });
- }
-};
-} // namespace
-
//===----------------------------------------------------------------------===//
// LinkerOptionsOp
//===----------------------------------------------------------------------===//
@@ -3991,9 +3961,6 @@ void LLVMDialect::initialize() {
// Support unknown operations because not all LLVM operations are registered.
allowUnknownOperations();
- // clang-format off
- addInterfaces<LLVMOpAsmDialectInterface>();
- // clang-format on
declarePromisedInterface<DialectInlinerInterface, LLVMDialect>();
}
More information about the Mlir-commits
mailing list