diff options
author | River Riddle <riddleriver@gmail.com> | 2022-08-11 20:06:33 -0700 |
---|---|---|
committer | River Riddle <riddleriver@gmail.com> | 2022-08-22 00:36:26 -0700 |
commit | f3acb54c1b7b7721cea5c07f64194151dddd3c4b (patch) | |
tree | 68ded4bfe2f55f9f48a4f0e20adfc1acf21829b4 /mlir/lib/Parser | |
parent | e587199a505bf517935026e878fc811a38532e4a (diff) | |
download | llvm-f3acb54c1b7b7721cea5c07f64194151dddd3c4b.tar.gz |
[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
Diffstat (limited to 'mlir/lib/Parser')
-rw-r--r-- | mlir/lib/Parser/CMakeLists.txt | 1 | ||||
-rw-r--r-- | mlir/lib/Parser/Parser.cpp | 3 |
2 files changed, 4 insertions, 0 deletions
diff --git a/mlir/lib/Parser/CMakeLists.txt b/mlir/lib/Parser/CMakeLists.txt index 7875b0fe5e74..9dcbb63dfdf7 100644 --- a/mlir/lib/Parser/CMakeLists.txt +++ b/mlir/lib/Parser/CMakeLists.txt @@ -6,5 +6,6 @@ add_mlir_library(MLIRParser LINK_LIBS PUBLIC MLIRAsmParser + MLIRBytecodeReader MLIRIR ) diff --git a/mlir/lib/Parser/Parser.cpp b/mlir/lib/Parser/Parser.cpp index 270e1d6f513f..4c0742895b60 100644 --- a/mlir/lib/Parser/Parser.cpp +++ b/mlir/lib/Parser/Parser.cpp @@ -12,6 +12,7 @@ #include "mlir/Parser/Parser.h" #include "mlir/AsmParser/AsmParser.h" +#include "mlir/Bytecode/BytecodeReader.h" #include "llvm/Support/SourceMgr.h" using namespace mlir; @@ -25,6 +26,8 @@ LogicalResult mlir::parseSourceFile(const llvm::SourceMgr &sourceMgr, sourceBuf->getBufferIdentifier(), /*line=*/0, /*column=*/0); } + if (isBytecode(*sourceBuf)) + return readBytecodeFile(*sourceBuf, block, config); return parseAsmSourceFile(sourceMgr, block, config); } |