[all-commits] [llvm/llvm-project] be26be: [mlir] Separate enum information from attributes, ...

Krzysztof Drewniak via All-commits all-commits at lists.llvm.org
Wed Mar 19 21:42:56 PDT 2025


  Branch: refs/heads/users/krzysz00/refactor-enum-enum-attr
  Home:   https://github.com/llvm/llvm-project
  Commit: be26be628f4600f89d3f79811eee75b2a02ac062
      https://github.com/llvm/llvm-project/commit/be26be628f4600f89d3f79811eee75b2a02ac062
  Author: Krzysztof Drewniak <krzysdrewniak at gmail.com>
  Date:   2025-03-19 (Wed, 19 Mar 2025)

  Changed paths:
    M mlir/include/mlir/Dialect/LLVMIR/LLVMEnums.td
    M mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td
    M mlir/include/mlir/IR/EnumAttr.td
    M mlir/include/mlir/IR/Properties.td
    M mlir/include/mlir/TableGen/Attribute.h
    A mlir/include/mlir/TableGen/EnumInfo.h
    M mlir/include/mlir/TableGen/Pattern.h
    M mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
    M mlir/lib/TableGen/Attribute.cpp
    M mlir/lib/TableGen/CMakeLists.txt
    A mlir/lib/TableGen/EnumInfo.cpp
    M mlir/lib/TableGen/Pattern.cpp
    M mlir/test/Dialect/LLVMIR/func.mlir
    M mlir/test/IR/attribute.mlir
    M mlir/test/IR/enum-attr-invalid.mlir
    M mlir/test/IR/enum-attr-roundtrip.mlir
    M mlir/test/lib/Dialect/Test/TestEnumDefs.td
    M mlir/test/lib/Dialect/Test/TestOps.td
    M mlir/test/mlir-tblgen/enums-gen.td
    M mlir/tools/mlir-tblgen/EnumPythonBindingGen.cpp
    M mlir/tools/mlir-tblgen/EnumsGen.cpp
    M mlir/tools/mlir-tblgen/LLVMIRConversionGen.cpp
    M mlir/tools/mlir-tblgen/OpDocGen.cpp
    M mlir/tools/mlir-tblgen/OpFormatGen.cpp
    M mlir/tools/mlir-tblgen/RewriterGen.cpp
    M mlir/tools/mlir-tblgen/SPIRVUtilsGen.cpp
    M mlir/tools/mlir-tblgen/TosaUtilsGen.cpp
    M mlir/utils/spirv/gen_spirv_dialect.py

  Log Message:
  -----------
  [mlir] Separate enum information from attributes, improve EnumProp

This commit pulls apart the inherent attribute dependence of classes
like EnumAttrInfo and EnumAttrCase, factoring them out into simpler
EnumCase and EnumInfo variants. This allows specifying the cases of an
enum without needing to make the cases, or the EnumInfo itself, a
subclass of SignlessIntegerAttrBase.

The existing classes are retained as subclasses of the new ones, both
for backwards compatibility and to allow attribute-specific
information.

In addition, the new BitEnum class changes its default printer/parser
behavior: cases when multiple keywords appear, like having both nuw
and nsw in overflow flags, will no longer be quoted by the operator<<,
and the FieldParser instance will now expect multiple keywords. All
instances of BitEnumAttr retain the old behavior.

Finally, this commit improves the `EnumProp` class, causing it to wrap
around an `EnumInfo` just like `EnumAttr` does, and introducing logic
for converting to/from attributes and bitcode (while using
autogenerated parsers and printers). The commit also provides the
`NamedEnumProp` class for the common pattern of `name<enum_value>` in
MLIR code, and provides `EnumPropWithAttrForm` to allow upgrading enum
attributes to properties without breaking the generic form of
assembly.

(Sadly, bitcode auto-upgrade is hampered by the lack of the ability to
optionally parse an attribute.)



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list