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
11
12namespace bb::avm2::simulation {
13
14enum class AddressingEventError : uint8_t {
15 // The base address (mem[0]) points to a MemoryValue not of the
16 // right tag (not MemoryAddressTag).
18 // The relative computation overflowed the max memory address.
20 // The address obtained after applying indirection points to
21 // a MemoryValue not of the right tag (not MemoryAddressTag).
23};
24
25inline std::string to_string(AddressingEventError e)
26{
27 switch (e) {
29 return "BASE_ADDRESS_INVALID";
31 return "RELATIVE_COMPUTATION_OOB";
33 return "INVALID_ADDRESS_AFTER_INDIRECTION";
34 }
35
36 // We should be catching all the cases above.
37 __builtin_unreachable();
38}
39
40struct AddressingException : public std::runtime_error {
41 explicit AddressingException(const std::string& message = "Error resolving operands.")
42 : std::runtime_error(message)
43 {}
44};
45
46// This represents the resolution of a single operand.
47// The operand can be either an immediate or an address.
48// If it is an address, we can apply relative addressing and indirection to it.
49// We will store the result of the resolution in the resolved_operand field.
50// An immediate operand will never have an error and both resolved_operand
51// and after_relative will be the same as the original operand.
52// Note: after_relative does not need the tag information in trace generation
58
59// We initialize base_address so that tag and value are 0
60// in the trace when no relative addressing is used.
63 std::vector<OperandResolutionInfo> resolution_info; // One entry per operand (including immediates).
64};
65
66} // namespace bb::avm2::simulation
static TaggedValue from_tag(ValueTag tag, FF value)
std::string to_string(const std::array< FF, N > &arr)
Definition stringify.hpp:31
AvmFlavorSettings::FF FF
Definition field.hpp:10
STL namespace.
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13
std::vector< OperandResolutionInfo > resolution_info
AddressingException(const std::string &message="Error resolving operands.")
std::optional< AddressingEventError > error