Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
gas.cpp
Go to the documentation of this file.
1
#include "
barretenberg/vm2/common/gas.hpp
"
2
3
#include <cstddef>
4
5
#include "
barretenberg/vm2/common/addressing.hpp
"
6
#include "
barretenberg/vm2/common/aztec_constants.hpp
"
7
8
namespace
bb::avm2
{
9
10
uint32_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
aztec_constants.hpp
AVM_MAX_OPERANDS
#define AVM_MAX_OPERANDS
Definition
aztec_constants.hpp:196
AVM_ADDRESSING_INDIRECT_L2_GAS
#define AVM_ADDRESSING_INDIRECT_L2_GAS
Definition
aztec_constants.hpp:199
AVM_ADDRESSING_RELATIVE_L2_GAS
#define AVM_ADDRESSING_RELATIVE_L2_GAS
Definition
aztec_constants.hpp:200
AVM_ADDRESSING_BASE_RESOLUTION_L2_GAS
#define AVM_ADDRESSING_BASE_RESOLUTION_L2_GAS
Definition
aztec_constants.hpp:198
addressing.hpp
gas.hpp
bb::avm2
Definition
flavor.hpp:472
bb::avm2::is_operand_relative
bool is_operand_relative(uint16_t indirect_flag, size_t operand_index)
Definition
addressing.hpp:8
bb::avm2::compute_addressing_gas
uint32_t compute_addressing_gas(uint16_t indirect_flag)
Definition
gas.cpp:10
bb::avm2::is_operand_indirect
bool is_operand_indirect(uint16_t indirect_flag, size_t operand_index)
Definition
addressing.hpp:13
src
barretenberg
vm2
common
gas.cpp
Generated by
1.9.8