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 defvars 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.