[Mlir-commits] [mlir] [mlir][LLVMIR][NFC] Migrate to OpAsmAttrInterface for ASM alias generation (PR #130479)
Hongren Zheng
llvmlistbot at llvm.org
Sun Mar 16 00:29:15 PDT 2025
================
@@ -13,13 +13,30 @@ include "mlir/Dialect/LLVMIR/LLVMDialect.td"
include "mlir/Dialect/LLVMIR/LLVMInterfaces.td"
include "mlir/IR/AttrTypeBase.td"
include "mlir/IR/CommonAttrConstraints.td"
+include "mlir/IR/OpAsmInterface.td"
// All of the attributes will extend this class.
class LLVM_Attr<string name, string attrMnemonic,
list<Trait> traits = [],
string baseCppClass = "::mlir::Attribute">
- : AttrDef<LLVM_Dialect, name, traits, baseCppClass> {
+ : AttrDef<LLVM_Dialect, name, traits # [OpAsmAttrInterface], baseCppClass> {
let mnemonic = attrMnemonic;
+
+ // Custom flag for attribute to indicate whether it wants mnemonic alias.
+ int enableMnemonicAlias = 0;
+ // If the attribute already uses extraClassDeclaration, it should create
+ // its own OpAsmAttrInterface methods instead of relying on here as this
+ // part will be overriden.
+ let extraClassDeclaration = !if(!eq(enableMnemonicAlias, 1), [{
+ //===------------------------------------------------------------------===//
+ // OpAsmAttrInterface Methods
+ //===------------------------------------------------------------------===//
+
+ ::mlir::OpAsmAliasResult getAlias(::llvm::raw_ostream &os) const {
+ os << "}] # mnemonic # [{";
+ return ::mlir::OpAsmAliasResult::OverridableAlias;
+ }
----------------
ZenithalHourlyRate wrote:
Formed a PR on tablegen in #131504. Lets see how people would say about this (namely is it worth it)
https://github.com/llvm/llvm-project/pull/130479
More information about the Mlir-commits
mailing list