Files
clang-p2996/mlir/test/IR/properties-bytecode-roundtrip.mlir
Markus Böck f117bbca04 [mlir] Add opt-in default property bytecode read and write implementation
Using properties currently requires at the very least implementing four methods/code snippets:
* `convertToAttribute`
* `convertFromAttribute`
* `writeToMlirBytecode`
* `readFromMlirBytecode`

This makes replacing attributes with properties harder than it has to be: Attributes by default do not require immediately defining custom bytecode encoding.

This patch therefore adds opt-in implementations of `writeToMlirBytecode` and `readFromMlirBytecode` that work with the default implementations of `convertToAttribute` and `convertFromAttribute`. They are provided by `defvar`s in `OpBase.td` and can be used by adding:
```
let writeToMlirBytecode = writeMlirBytecodeWithConvertToAttribute;
let readFromMlirBytecode = readMlirBytecodeUsingConvertFromAttribute;
```
to ones TableGen definition.

While this bytecode encoding is almost certainly not ideal for a given property, it allows more incremental use of properties and getting something sane working before optimizing the bytecode format.

Differential Revision: https://reviews.llvm.org/D155286
2023-07-21 08:03:26 +02:00

6 lines
222 B
MLIR

// RUN: mlir-opt -emit-bytecode %s | mlir-opt | FileCheck %s
// CHECK-LABEL: "test.using_int_property_with_worse_bytecode"
// CHECK-SAME: value = 3
"test.using_int_property_with_worse_bytecode"() <{value = 3}> : () -> ()