From 720da20588e0e984b1c1ff5eb63b84206b026d65 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 11 Feb 2021 11:08:54 +0100 Subject: [PATCH] Describe serialization format --- cranelift/codegen/src/ir/layout.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/cranelift/codegen/src/ir/layout.rs b/cranelift/codegen/src/ir/layout.rs index 9359c309df..f6272199bb 100644 --- a/cranelift/codegen/src/ir/layout.rs +++ b/cranelift/codegen/src/ir/layout.rs @@ -781,6 +781,17 @@ impl<'f> DoubleEndedIterator for Insts<'f> { } } +/// A custom serialize and deserialize implementation for [`Layout`]. +/// +/// This doesn't use a derived implementation as [`Layout`] is a manual implementation of a linked +/// list. Storing it directly as a regular list saves a lot of space. +/// +/// The following format is used. (notated in EBNF form) +/// +/// ```plain +/// data = block_data * ; +/// block_data = "block_id" , "inst_count" , ( "inst_id" * ) ; +/// ``` #[cfg(feature = "enable-serde")] mod serde { use ::serde::de::{Deserializer, Error, SeqAccess, Visitor};