[all-commits] [llvm/llvm-project] b7e847: [mlir] Improve EnumProp, making it take an EnumInfo

Krzysztof Drewniak via All-commits all-commits at lists.llvm.org
Sun Mar 23 18:33:58 PDT 2025


  Branch: refs/heads/users/krzysz00/new-enum-prop
  Home:   https://github.com/llvm/llvm-project
  Commit: b7e84740dbe3795a87deb0e7b7fe5d92d181f7b1
      https://github.com/llvm/llvm-project/commit/b7e84740dbe3795a87deb0e7b7fe5d92d181f7b1
  Author: Krzysztof Drewniak <krzysdrewniak at gmail.com>
  Date:   2025-03-23 (Sun, 23 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/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
    M mlir/test/IR/enum-attr-invalid.mlir
    M mlir/test/IR/enum-attr-roundtrip.mlir
    M mlir/test/lib/Dialect/Test/TestOps.td

  Log Message:
  -----------
  [mlir] Improve EnumProp, making it take an EnumInfo

This commit improves the `EnumProp` class, causing it to wrap around
an `EnumInfo` just like` EnumAttr` does. This EnumProp also has logic
for converting to/from an integer attribute and for being read and
written as bitcode.

The following variants of `EnumProp` are provided:
- `EnumPropWithAttrForm` - an EnumProp that can be constructed
from (and will be converted to, if `storeInCustomAttribute` is true) a
custom attribute, like an `EnumAttr`, instead of a plain integer. This
is meant for backwards compatibility with code that uses enum
attributes.

`NamedEnumProp` adds a "`mnemonic` `<` $enum `>`" syntax around the
enum, replicating a common pattern seen in MLIR printers and
allowing for reduced ambiguity.

`NamedEnumPropWithAttrForm` combines both of these extensions.

(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