Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
addressing_event.hpp
Go to the documentation of this file.
1
#pragma once
2
3
#include <cstdint>
4
#include <optional>
5
#include <stdexcept>
6
#include <string>
7
#include <vector>
8
9
#include "
barretenberg/vm2/common/memory_types.hpp
"
10
#include "
barretenberg/vm2/simulation/lib/serialization.hpp
"
11
12
namespace
bb::avm2::simulation
{
13
14
enum class
AddressingEventError
{
15
// The base address (mem[0]) is not a valid address.
16
BASE_ADDRESS_INVALID
,
17
// The relative computation overflowed.
18
RELATIVE_COMPUTATION_OOB
,
19
// The address obtained after applying indirection is not a valid address.
20
INVALID_ADDRESS_AFTER_INDIRECTION
,
21
};
22
23
inline
std::string
to_string
(
AddressingEventError
e)
24
{
25
switch
(e) {
26
case
AddressingEventError::BASE_ADDRESS_INVALID
:
27
return
"BASE_ADDRESS_INVALID"
;
28
case
AddressingEventError::RELATIVE_COMPUTATION_OOB
:
29
return
"RELATIVE_COMPUTATION_OOB"
;
30
case
AddressingEventError::INVALID_ADDRESS_AFTER_INDIRECTION
:
31
return
"INVALID_ADDRESS_AFTER_INDIRECTION"
;
32
}
33
34
// We should be catching all the cases above.
35
__builtin_unreachable();
36
}
37
38
struct
AddressingException
:
public
std::runtime_error {
39
explicit
AddressingException
()
40
:
std
::runtime_error(
"Error resolving operands."
)
41
{}
42
};
43
44
struct
OperandResolutionInfo
{
45
Operand
after_relative
;
46
Operand
resolved_operand
;
47
std::optional<AddressingEventError>
error
;
48
};
49
50
// See https://docs.google.com/document/d/1EgFj0OQYZCWufjzLgoAAiVL9jV0-fUAaCCIVlvRc8bY/ for circuit details.
51
// - The activation mask can be derived from spec.num_addresses.
52
struct
AddressingEvent
{
53
Instruction
instruction
;
54
MemoryValue
base_address
;
55
std::vector<OperandResolutionInfo>
resolution_info
;
// One per operand (including immediates).
56
};
57
58
}
// namespace bb::avm2::simulation
bb::avm2::TaggedValue
Definition
tagged_value.hpp:70
memory_types.hpp
bb::avm2::simulation
Definition
address_derivation.cpp:8
bb::avm2::simulation::to_string
std::string to_string(AddressingEventError e)
Definition
addressing_event.hpp:23
bb::avm2::simulation::AddressingEventError
AddressingEventError
Definition
addressing_event.hpp:14
bb::avm2::simulation::AddressingEventError::BASE_ADDRESS_INVALID
@ BASE_ADDRESS_INVALID
bb::avm2::simulation::AddressingEventError::RELATIVE_COMPUTATION_OOB
@ RELATIVE_COMPUTATION_OOB
bb::avm2::simulation::AddressingEventError::INVALID_ADDRESS_AFTER_INDIRECTION
@ INVALID_ADDRESS_AFTER_INDIRECTION
std
STL namespace.
std::get
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition
tuple.hpp:13
serialization.hpp
bb::avm2::simulation::AddressingEvent
Definition
addressing_event.hpp:52
bb::avm2::simulation::AddressingEvent::base_address
MemoryValue base_address
Definition
addressing_event.hpp:54
bb::avm2::simulation::AddressingEvent::resolution_info
std::vector< OperandResolutionInfo > resolution_info
Definition
addressing_event.hpp:55
bb::avm2::simulation::AddressingEvent::instruction
Instruction instruction
Definition
addressing_event.hpp:53
bb::avm2::simulation::AddressingException
Definition
addressing_event.hpp:38
bb::avm2::simulation::AddressingException::AddressingException
AddressingException()
Definition
addressing_event.hpp:39
bb::avm2::simulation::Instruction
Definition
serialization.hpp:30
bb::avm2::simulation::OperandResolutionInfo
Definition
addressing_event.hpp:44
bb::avm2::simulation::OperandResolutionInfo::after_relative
Operand after_relative
Definition
addressing_event.hpp:45
bb::avm2::simulation::OperandResolutionInfo::resolved_operand
Operand resolved_operand
Definition
addressing_event.hpp:46
bb::avm2::simulation::OperandResolutionInfo::error
std::optional< AddressingEventError > error
Definition
addressing_event.hpp:47
src
barretenberg
vm2
simulation
events
addressing_event.hpp
Generated by
1.9.8