You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To serialise a `::goto_modelt` instance `gm` to a stream `ostr` call the
347
+
function `::write_goto_binary`, e.g. `write_goto_binary(ostr, gm)`.
348
+
349
+
The content of the written stream will have this structure:
350
+
- The header:
351
+
- A magic number: byte `0x7f` followed by 3 characters `GBF`.
352
+
- A version number written in the 7-bit encoding (see [number serialisation](\ref irep-serialization-numbers)). Currently, only version `4` is supported.
353
+
- The symbol table:
354
+
- The number of symbols in the table in the 7-bit encoding.
355
+
- The array of individual symbols in the table. Each written symbol `s` has this structure:
356
+
- The `::irept` instance `s.type`.
357
+
- The `::irept` instance `s.value`.
358
+
- The `::irept` instance `s.location`.
359
+
- The string `s.name`.
360
+
- The string `s.module`.
361
+
- The string `s.base_name`.
362
+
- The string `s.mode`.
363
+
- The string `s.pretty_name`.
364
+
- The number `0` in the 7-bit encoding.
365
+
- The flags word in the 7-bit encoding. The bits in the flags word correspond to the following `Boolean` fields (from the most significant bit):
366
+
-`s.is_weak`
367
+
-`s.is_type`
368
+
-`s.is_property`
369
+
-`s.is_macro`
370
+
-`s.is_exported`
371
+
-`s.is_input`
372
+
-`s.is_output`
373
+
-`s.is_state_var`
374
+
-`s.is_parameter`
375
+
-`s.is_auxiliary`
376
+
-`0` (corresponding to `s.binding`, i.e. we always clear this info)
377
+
-`s.is_lvalue`
378
+
-`s.is_static_lifetime`
379
+
-`s.is_thread_local`
380
+
-`s.is_file_local`
381
+
-`s.is_extern`
382
+
-`s.is_volatile`
383
+
- The functions with bodies, i.e. those missing a body are skipped.
384
+
- The number of functions with bodies in the 7-bit encoding.
385
+
- The array of individual functions with bodies. Each written function has this structure:
386
+
- The string with the name of the function.
387
+
- The number of instructions in the body of the function in the 7-bit encoding.
388
+
- The array of individual instructions in function's body. Each written instruction `I` has this structure:
389
+
- The `::irept` instance `I.code`, i.e. data of the instruction, like arguments.
390
+
- The string `I.function`, i.e. the name of the function this instruction belongs to.
391
+
- The `::irept` instance `I.source_location`, i.e. the reference to the original source code (file, line).
392
+
- The word in the 7-bit encoding `I.type`, i.e. the op-code of the instruction.
393
+
- The `::irept` instance `I.guard`.
394
+
- The empty string (representing former `I.event`).
395
+
- The word in the 7-bit encoding `I.target_number`, i.e. the jump target to this instruction from other instructions.
396
+
- The word in the 7-bit encoding `I.targets.size()`, i.e. the count of jump targets from this instruction.
397
+
- The array of individual jump targets from this instruction, each written as a word in the 7-bit encoding.
398
+
- The word in the 7-bit encoding `I.labels.size()`.
399
+
- The array of individual labels, each written as a word in the 7-bit encoding.
400
+
401
+
An important propery of the serialisation is that each serialised `::irept`
402
+
instance occurs in the stream exactly once. Namely, in the position of
403
+
its first serialisation query. All other such queries save only a hash
404
+
code (i.e. reference) of the `::irept` instance.
405
+
406
+
A similar strategy is used for serialisation of string constants
407
+
shared amongst `::irept` instances. Such a string is fully saved only in
408
+
the first serialisation query of an `::irept` instance it appears in and
409
+
all other queries only save its integer hash code.
410
+
411
+
Details about serialisation of `::irept` instances, strings, and words in
412
+
7-bit encoding can be found [here](\ref irep-serialization).
0 commit comments