[all-commits] [llvm/llvm-project] 60e34f: [mlir][ods] Remove StrEnumAttr

Jeff Niu via All-commits all-commits at lists.llvm.org
Wed Apr 13 10:49:15 PDT 2022

  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 60e34f8dddb4a3ae5b82e8d55728c021126c4af8
  Author: Mogball <jeffniu22 at gmail.com>
  Date:   2022-04-13 (Wed, 13 Apr 2022)

  Changed paths:
    M mlir/docs/OpDefinitions.md
    M mlir/include/mlir/IR/OpBase.td
    M mlir/include/mlir/TableGen/Attribute.h
    M mlir/lib/TableGen/Attribute.cpp
    M mlir/test/IR/attribute.mlir
    M mlir/test/lib/Dialect/Test/TestOps.td
    M mlir/test/mlir-tblgen/pattern.mlir
    M mlir/tools/mlir-tblgen/DirectiveCommonGen.cpp
    M mlir/tools/mlir-tblgen/EnumsGen.cpp
    M mlir/tools/mlir-tblgen/OpFormatGen.cpp
    M mlir/tools/mlir-tblgen/RewriterGen.cpp
    M mlir/unittests/TableGen/EnumsGenTest.cpp
    M mlir/unittests/TableGen/enums.td

  Log Message:
  [mlir][ods] Remove StrEnumAttr

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", "", [

// 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">;

Reviewed By: rriddle, jpienaar

Differential Revision: https://reviews.llvm.org/D120834

More information about the All-commits mailing list