[all-commits] [llvm/llvm-project] 5ecc0e: [mlir] Improve EnumProp, making it take an EnumInf...

Krzysztof Drewniak via All-commits all-commits at lists.llvm.org
Sun Apr 13 20:47:19 PDT 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 5ecc0ef6b01fe9dcca8fcaa8b306cd94c2239db4
      https://github.com/llvm/llvm-project/commit/5ecc0ef6b01fe9dcca8fcaa8b306cd94c2239db4
  Author: Krzysztof Drewniak <krzysdrewniak at gmail.com>
  Date:   2025-04-13 (Sun, 13 Apr 2025)

  Changed paths:
    M mlir/docs/DefiningDialects/Operations.md
    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 (#132349)

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, bytecode auto-upgrade is hampered by the lack of the ability to
optionally parse an attribute.)

Depends on #132148



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