[mlir] Add initial support for a binary serialization format
authorRiver Riddle <riddleriver@gmail.com>
Fri, 12 Aug 2022 03:06:33 +0000 (20:06 -0700)
committerRiver Riddle <riddleriver@gmail.com>
Mon, 22 Aug 2022 07:36:26 +0000 (00:36 -0700)
commitf3acb54c1b7b7721cea5c07f64194151dddd3c4b
tree68ded4bfe2f55f9f48a4f0e20adfc1acf21829b4
parente587199a505bf517935026e878fc811a38532e4a
[mlir] Add initial support for a binary serialization format

This commit adds a new bytecode serialization format for MLIR.
The actual serialization of MLIR to binary is relatively straightforward,
given the very very general structure of MLIR. The underlying basis for
this format is a variable-length encoding for integers, which gets heavily
used for nearly all aspects of the encoding (given that most of the encoding
is just indexing into lists).

The format currently does not provide support for custom attribute/type
serialization, and thus always uses an assembly format fallback. It also
doesn't provide support for resources. These will be added in followups,
the intention for this patch is to provide something that supports the
basic cases, and can be built on top of.

https://discourse.llvm.org/t/rfc-a-binary-serialization-format-for-mlir/63518

Differential Revision: https://reviews.llvm.org/D131747
49 files changed:
mlir/docs/BytecodeFormat.md [new file with mode: 0644]
mlir/include/mlir/Bytecode/BytecodeReader.h [new file with mode: 0644]
mlir/include/mlir/Bytecode/BytecodeWriter.h [new file with mode: 0644]
mlir/include/mlir/IR/OperationSupport.h
mlir/include/mlir/Tools/mlir-opt/MlirOptMain.h
mlir/lib/Bytecode/CMakeLists.txt [new file with mode: 0644]
mlir/lib/Bytecode/Encoding.h [new file with mode: 0644]
mlir/lib/Bytecode/Reader/BytecodeReader.cpp [new file with mode: 0644]
mlir/lib/Bytecode/Reader/CMakeLists.txt [new file with mode: 0644]
mlir/lib/Bytecode/Writer/BytecodeWriter.cpp [new file with mode: 0644]
mlir/lib/Bytecode/Writer/CMakeLists.txt [new file with mode: 0644]
mlir/lib/Bytecode/Writer/IRNumbering.cpp [new file with mode: 0644]
mlir/lib/Bytecode/Writer/IRNumbering.h [new file with mode: 0644]
mlir/lib/CMakeLists.txt
mlir/lib/Parser/CMakeLists.txt
mlir/lib/Parser/Parser.cpp
mlir/lib/Tools/mlir-opt/CMakeLists.txt
mlir/lib/Tools/mlir-opt/MlirOptMain.cpp
mlir/test/Bytecode/general.mlir [new file with mode: 0644]
mlir/test/Bytecode/invalid/invalid-attr_type_offset_section-large_offset.mlirbc [new file with mode: 0644]
mlir/test/Bytecode/invalid/invalid-attr_type_offset_section-trailing_data.mlirbc [new file with mode: 0644]
mlir/test/Bytecode/invalid/invalid-attr_type_section-index.mlirbc [new file with mode: 0644]
mlir/test/Bytecode/invalid/invalid-attr_type_section-trailing_data.mlirbc [new file with mode: 0644]
mlir/test/Bytecode/invalid/invalid-dialect_section-dialect_string.mlirbc [new file with mode: 0644]
mlir/test/Bytecode/invalid/invalid-dialect_section-opname_dialect.mlirbc [new file with mode: 0644]
mlir/test/Bytecode/invalid/invalid-dialect_section-opname_string.mlirbc [new file with mode: 0644]
mlir/test/Bytecode/invalid/invalid-dialect_section.mlir [new file with mode: 0644]
mlir/test/Bytecode/invalid/invalid-ir_section-attr.mlirbc [new file with mode: 0644]
mlir/test/Bytecode/invalid/invalid-ir_section-forwardref.mlirbc [new file with mode: 0644]
mlir/test/Bytecode/invalid/invalid-ir_section-loc.mlirbc [new file with mode: 0644]
mlir/test/Bytecode/invalid/invalid-ir_section-operands.mlirbc [new file with mode: 0644]
mlir/test/Bytecode/invalid/invalid-ir_section-opname.mlirbc [new file with mode: 0644]
mlir/test/Bytecode/invalid/invalid-ir_section-results.mlirbc [new file with mode: 0644]
mlir/test/Bytecode/invalid/invalid-ir_section-successors.mlirbc [new file with mode: 0644]
mlir/test/Bytecode/invalid/invalid-ir_section.mlir [new file with mode: 0644]
mlir/test/Bytecode/invalid/invalid-string_section-count.mlirbc [new file with mode: 0644]
mlir/test/Bytecode/invalid/invalid-string_section-large_string.mlirbc [new file with mode: 0644]
mlir/test/Bytecode/invalid/invalid-string_section-no_string.mlirbc [new file with mode: 0644]
mlir/test/Bytecode/invalid/invalid-string_section-trailing_data.mlirbc [new file with mode: 0644]
mlir/test/Bytecode/invalid/invalid-string_section.mlir [new file with mode: 0644]
mlir/test/Bytecode/invalid/invalid-structure-producer.mlirbc [new file with mode: 0644]
mlir/test/Bytecode/invalid/invalid-structure-section-duplicate.mlirbc [new file with mode: 0644]
mlir/test/Bytecode/invalid/invalid-structure-section-id-unknown.mlirbc [new file with mode: 0644]
mlir/test/Bytecode/invalid/invalid-structure-section-length.mlirbc [new file with mode: 0644]
mlir/test/Bytecode/invalid/invalid-structure-section-missing.mlirbc [new file with mode: 0644]
mlir/test/Bytecode/invalid/invalid-structure-version.mlirbc [new file with mode: 0644]
mlir/test/Bytecode/invalid/invalid-structure.mlir [new file with mode: 0644]
mlir/test/Bytecode/invalid/invalid_attr_type_offset_section.mlir [new file with mode: 0644]
mlir/test/Bytecode/invalid/invalid_attr_type_section.mlir [new file with mode: 0644]