This is an archive of the discontinued LLVM Phabricator instance.

[mlir][ods] Remove StrEnumAttr
ClosedPublic

Authored by Mogball on Mar 2 2022, 10:00 AM.

Details

Summary

StrEnumAttr has been deprecated in favour of EnumAttr, a solution based on AttrDef (https://reviews.llvm.org/D115181). This patch removes StrEnumAttr, along with all the custom ODS logic required to handle it.

See https://discourse.llvm.org/t/psa-stop-using-strenumattr-do-use-enumattr/5710 on how to transition to EnumAttr. In short,

// Before
def MyEnumAttr : StrEnumAttr<"MyEnum", "", [
  StrEnumAttrCase<"A">,
  StrEnumAttrCase<"B">
]>;

// After (pick an integer enum of your choice)
def MyEnum : I32EnumAttr<"MyEnum", "", [
  I32EnumAttrCase<"A", 0>,
  I32EnumAttrCase<"B", 1>
]> {
  // Don't generate a C++ class! We want to use the AttrDef
  let genSpecializedAttr = 0;
}
// Define the AttrDef
def MyEnum : EnumAttr<MyDialect, MyEnum, "my_enum">;

Diff Detail

Event Timeline

Mogball created this revision.Mar 2 2022, 10:00 AM
Herald added a project: Restricted Project. · View Herald Transcript
Mogball requested review of this revision.Mar 2 2022, 10:00 AM
rriddle accepted this revision.Mar 2 2022, 10:21 AM

Just confirming, do we have docs for the EnumAttr stuff? (Should be easier to add if not after D120011)

This revision is now accepted and ready to land.Mar 2 2022, 10:21 AM
rriddle added a comment.EditedMar 2 2022, 10:22 AM

If we don't yet have docs, can you add an EnumAttr-esque equivalent to the description as an example for users transitioning?

jpienaar accepted this revision.Mar 2 2022, 10:33 AM
jpienaar added a subscriber: jpienaar.

Nice!

Mogball edited the summary of this revision. (Show Details)Mar 2 2022, 10:39 AM

I don't think I had docs for EnumAttr. I updated the description, however.

This revision was automatically updated to reflect the committed changes.