Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
gas.cpp
Go to the documentation of this file.
2
3#include <cstddef>
4
7
8namespace bb::avm2 {
9
10uint32_t compute_addressing_gas(uint16_t indirect_flag)
11{
12 uint32_t indirect_operand_count = 0;
13 uint32_t relative_operand_count = 0;
14
15 for (size_t i = 0; i < AVM_MAX_OPERANDS; i++) {
16 if (is_operand_indirect(indirect_flag, i)) {
17 indirect_operand_count++;
18 }
19 if (is_operand_relative(indirect_flag, i)) {
20 relative_operand_count++;
21 }
22 }
23
24 return (relative_operand_count != 0 ? AVM_ADDRESSING_BASE_RESOLUTION_L2_GAS : 0) +
25 (indirect_operand_count * AVM_ADDRESSING_INDIRECT_L2_GAS) +
26 (relative_operand_count * AVM_ADDRESSING_RELATIVE_L2_GAS);
27}
28
29} // namespace bb::avm2
#define AVM_MAX_OPERANDS
#define AVM_ADDRESSING_INDIRECT_L2_GAS
#define AVM_ADDRESSING_RELATIVE_L2_GAS
#define AVM_ADDRESSING_BASE_RESOLUTION_L2_GAS
bool is_operand_relative(uint16_t indirect_flag, size_t operand_index)
Definition addressing.hpp:8
uint32_t compute_addressing_gas(uint16_t indirect_flag)
Definition gas.cpp:10
bool is_operand_indirect(uint16_t indirect_flag, size_t operand_index)