diff options
| author | Mehdi Amini <joker.eph@gmail.com> | 2023-04-29 02:36:45 -0700 |
|---|---|---|
| committer | Mehdi Amini <joker.eph@gmail.com> | 2023-05-20 15:24:33 -0700 |
| commit | 3128b3105d7a226fc26174be265da479ff619f3e (patch) | |
| tree | 07a0b642d033b5622d1bb36254faf3b12af79ee6 /mlir/lib/Bytecode/Writer/BytecodeWriter.cpp | |
| parent | e8cc0d310c4060b605dc293bff5d2bca95ff528b (diff) | |
Add support for Lazyloading to the MLIR bytecode
IsolatedRegions are emitted in sections in order for the reader to be
able to skip over them. A new class is exposed to manage the state and
allow the readers to load these IsolatedRegions on-demand.
Differential Revision: https://reviews.llvm.org/D149515
Diffstat (limited to 'mlir/lib/Bytecode/Writer/BytecodeWriter.cpp')
| -rw-r--r-- | mlir/lib/Bytecode/Writer/BytecodeWriter.cpp | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/mlir/lib/Bytecode/Writer/BytecodeWriter.cpp b/mlir/lib/Bytecode/Writer/BytecodeWriter.cpp index 801f3022d0e4..158dbe6d161d 100644 --- a/mlir/lib/Bytecode/Writer/BytecodeWriter.cpp +++ b/mlir/lib/Bytecode/Writer/BytecodeWriter.cpp @@ -734,8 +734,18 @@ void BytecodeWriter::writeOp(EncodingEmitter &emitter, Operation *op) { bool isIsolatedFromAbove = op->hasTrait<OpTrait::IsIsolatedFromAbove>(); emitter.emitVarIntWithFlag(numRegions, isIsolatedFromAbove); - for (Region ®ion : op->getRegions()) - writeRegion(emitter, ®ion); + for (Region ®ion : op->getRegions()) { + // If the region is not isolated from above, or we are emitting bytecode + // targetting version <2, we don't use a section. + if (!isIsolatedFromAbove || config.bytecodeVersion < 2) { + writeRegion(emitter, ®ion); + continue; + } + + EncodingEmitter regionEmitter; + writeRegion(regionEmitter, ®ion); + emitter.emitSection(bytecode::Section::kIR, std::move(regionEmitter)); + } } } |
