42 .after_relative = operand.as_ff(),
43 .resolved_operand = operand,
58 bool has_relative_address =
false;
61 has_relative_address =
true;
68 bool base_address_invalid =
false;
70 if (has_relative_address) {
71 base_address =
memory.get(0);
72 event.base_address = *base_address;
74 if (!
memory.is_valid_address(*base_address)) {
75 base_address_invalid =
true;
83 auto& resolution_info =
event.resolution_info[i];
98 if (base_address_invalid) {
109 auto offset =
static_cast<uint64_t
>(resolution_info.after_relative);
114 resolution_info.after_relative =
FF(
offset);
134 const auto after_relative_address =
static_cast<MemoryAddress>(resolution_info.after_relative);
135 resolution_info.resolved_operand =
Operand::from(after_relative_address);
137 resolution_info.resolved_operand =
memory.get(after_relative_address);
139 if (!
memory.is_valid_address(resolution_info.resolved_operand)) {
150 debug(
"Base address: ",
event.base_address.to_string());
151 debug(
"After relative: ", resolution_info.after_relative);
152 debug(
"Resolved operand: ", resolution_info.resolved_operand.to_string());
153 resolution_info.error = e;
160 if (std::ranges::any_of(
event.resolution_info, [](
const auto&
info) { return info.error.has_value(); })) {
168 resolved_operands.reserve(
event.resolution_info.size());
169 for (
const auto&
info :
event.resolution_info) {
170 resolved_operands.push_back(
info.resolved_operand);
172 return resolved_operands;
#define BB_ASSERT_DEBUG(expression,...)
#define BB_ASSERT_LTE(left, right,...)
#define AVM_HIGHEST_MEM_ADDRESS
#define BB_BENCH_NAME(name)
static TaggedValue from(T value)
static TaggedValue from_tag(ValueTag tag, FF value)
EventEmitterInterface< AddressingEvent > & events
bool is_address_out_of_range(uint64_t address)
Checks if an address as uint64_t is out of range. Emits a gt event comparing the address to AVM_HIGHE...
std::vector< Operand > resolve(const Instruction &instruction, MemoryInterface &memory) override
Resolve the operands of an instruction. If the operands are non-addresses, they are returned as is....
const InstructionInfoDBInterface & instruction_info_db
virtual const ExecInstructionSpec & get(ExecutionOpCode opcode) const =0
AVM range check gadget for witness generation.
@ RELATIVE_COMPUTATION_OOB
@ INVALID_ADDRESS_AFTER_INDIRECTION
std::string to_string(const std::array< FF, N > &arr)
bool is_operand_relative(uint16_t indirect_flag, size_t operand_index)
Checks if the operand at the given index is relative.
bool is_operand_indirect(uint16_t indirect_flag, size_t operand_index)
Checks if the operand at the given index is indirect.
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
simulation::PublicDataTreeReadWriteEvent event
std::vector< OperandResolutionInfo > resolution_info