[mlir:Bytecode] Add initial support for dialect defined attribute/type encodings
authorRiver Riddle <riddleriver@gmail.com>
Tue, 23 Aug 2022 19:56:02 +0000 (12:56 -0700)
committerRiver Riddle <riddleriver@gmail.com>
Tue, 23 Aug 2022 23:56:04 +0000 (16:56 -0700)
commit02c2ecb9c6c355b8b6f650d258077bd9cca0aacf
tree34d382b3ced1d68f538291ed70fd6f5171d14fed
parentb3449392f55739ec950b038f6a81e5c0a5ef0cae
[mlir:Bytecode] Add initial support for dialect defined attribute/type encodings

Dialects can opt-in to providing custom encodings by implementing the
`BytecodeDialectInterface`. This interface provides hooks, namely
`readAttribute`/`readType` and `writeAttribute`/`writeType`, that will be used
by the bytecode reader and writer. These hooks are provided a reader and writer
implementation that can be used to encode various constructs in the underlying
bytecode format. A unique feature of this interface is that dialects may choose
to only encode a subset of their attributes and types in a custom bytecode
format, which can simplify adding new or experimental components that aren't
fully baked.

Differential Revision: https://reviews.llvm.org/D132498
14 files changed:
mlir/docs/BytecodeFormat.md
mlir/include/mlir/Bytecode/BytecodeImplementation.h [new file with mode: 0644]
mlir/include/mlir/IR/DialectInterface.h
mlir/lib/Bytecode/Reader/BytecodeReader.cpp
mlir/lib/Bytecode/Writer/BytecodeWriter.cpp
mlir/lib/Bytecode/Writer/IRNumbering.cpp
mlir/lib/Bytecode/Writer/IRNumbering.h
mlir/lib/IR/BuiltinDialect.cpp
mlir/lib/IR/BuiltinDialectBytecode.cpp [new file with mode: 0644]
mlir/lib/IR/BuiltinDialectBytecode.h [new file with mode: 0644]
mlir/lib/IR/CMakeLists.txt
mlir/lib/IR/Dialect.cpp
mlir/test/Dialect/Builtin/Bytecode/attrs.mlir [new file with mode: 0644]
mlir/test/Dialect/Builtin/Bytecode/types.mlir [new file with mode: 0644]