[Mlir-commits] [mlir] [mlir] Add def to `Properties.td` to help with enum properties (PR #89311)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Thu Apr 18 14:08:40 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-mlir
Author: Jeff Niu (Mogball)
<details>
<summary>Changes</summary>
This is useful for defining operation properties that are enums.
---
Full diff: https://github.com/llvm/llvm-project/pull/89311.diff
1 Files Affected:
- (modified) mlir/include/mlir/IR/Properties.td (+13)
``````````diff
diff --git a/mlir/include/mlir/IR/Properties.td b/mlir/include/mlir/IR/Properties.td
index 99da1763524fa9..0babdbbfa05bc2 100644
--- a/mlir/include/mlir/IR/Properties.td
+++ b/mlir/include/mlir/IR/Properties.td
@@ -153,4 +153,17 @@ class ArrayProperty<string storageTypeParam = "", int n, string desc = ""> :
let assignToStorage = "::llvm::copy($_value, $_storage)";
}
+class EnumProperty<string storageTypeParam, string desc = ""> :
+ Property<storageTypeParam, desc> {
+ code writeToMlirBytecode = [{
+ $_writer.writeVarInt(static_cast<uint64_t>($_storage));
+ }];
+ code readFromMlirBytecode = [{
+ uint64_t val;
+ if (failed($_reader.readVarInt(val)))
+ return ::mlir::failure();
+ $_storage = static_cast<}] # storageTypeParam # [{>(val);
+ }];
+}
+
#endif // PROPERTIES
``````````
</details>
https://github.com/llvm/llvm-project/pull/89311
More information about the Mlir-commits
mailing list