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

Krzysztof Drewniak via All-commits all-commits at lists.llvm.org
Thu Mar 27 17:44:48 PDT 2025


  Branch: refs/heads/users/krzysz00/new-enum-prop
  Home:   https://github.com/llvm/llvm-project
  Commit: 4181f255c2147e507bfaa7fecd6092453158ad84
      https://github.com/llvm/llvm-project/commit/4181f255c2147e507bfaa7fecd6092453158ad84
  Author: Krzysztof Drewniak <krzysdrewniak at gmail.com>
  Date:   2025-03-27 (Thu, 27 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