Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
serialization.hpp
Go to the documentation of this file.
1#pragma once
2
8
9#include <cstdint>
10#include <memory>
11#include <variant>
12#include <vector>
13
14namespace bb::avm2::simulation {
15
16// Possible types for an instruction's operand in its wire format.
17// The counterpart TS file is: avm/serialization/instruction_serialization.ts.
18// INDIRECT is parsed as UINT8 where the bits represent the operands that have indirect mem access.
20
21namespace testonly {
22
25
26} // namespace testonly
27
29
32 uint16_t indirect = 0;
34
35 std::string to_string() const;
36
37 // Serialize the instruction according to the specification from OPCODE_WIRE_FORMAT.
38 // There is no validation that the instructions operands comply to the format. Namely,
39 // they are casted according to the operand variant specified in format (throw only in
40 // truncation case). If the number of operands is larger than specified in format,
41 // no error will be thrown neither.
42 std::vector<uint8_t> serialize() const;
43
44 size_t size_in_bytes() const;
46
47 bool operator==(const Instruction& other) const = default;
48};
49
50enum class InstrDeserializationError : uint8_t {
55 // FIXME: remove this once all execution opcodes are supported.
56 // Also uncomment proper constraining of error in instr_fetching.pil.
58};
59
71
82
83} // namespace bb::avm2::simulation
Instruction instruction
const std::unordered_map< OperandType, uint32_t > & get_operand_type_sizes()
const std::unordered_map< WireOpCode, std::vector< OperandType > > & get_instruction_wire_formats()
bool check_tag(const Instruction &instruction)
Check whether the instruction must have a tag operand and whether the operand value is in the value t...
Instruction deserialize_instruction(std::span< const uint8_t > bytecode, size_t pos)
Parsing of an instruction in the supplied bytecode at byte position pos. This checks that the WireOpC...
AvmFlavorSettings::FF FF
Definition field.hpp:10
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13
std::vector< uint8_t > serialize() const
bool operator==(const Instruction &other) const =default
std::vector< Operand > operands
ExecutionOpCode get_exec_opcode() const