Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Use prefix op_ for every instruction in avm_trace.hpp #7214

Merged
merged 1 commit into from
Jun 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_execution.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -433,11 +433,11 @@ std::vector<Row> Execution::gen_trace(std::vector<Instruction> const& instructio
break;
// Execution Environment - Calldata
case OpCode::CALLDATACOPY:
trace_builder.calldata_copy(std::get<uint8_t>(inst.operands.at(0)),
std::get<uint32_t>(inst.operands.at(1)),
std::get<uint32_t>(inst.operands.at(2)),
std::get<uint32_t>(inst.operands.at(3)),
calldata);
trace_builder.op_calldata_copy(std::get<uint8_t>(inst.operands.at(0)),
std::get<uint32_t>(inst.operands.at(1)),
std::get<uint32_t>(inst.operands.at(2)),
std::get<uint32_t>(inst.operands.at(3)),
calldata);
break;
// Machine State - Gas
case OpCode::L2GASLEFT:
Expand Down Expand Up @@ -543,18 +543,18 @@ std::vector<Row> Execution::gen_trace(std::vector<Instruction> const& instructio
break;
// Machine State - Internal Control Flow
case OpCode::JUMP:
trace_builder.jump(std::get<uint32_t>(inst.operands.at(0)));
trace_builder.op_jump(std::get<uint32_t>(inst.operands.at(0)));
break;
case OpCode::JUMPI:
trace_builder.jumpi(std::get<uint8_t>(inst.operands.at(0)),
std::get<uint32_t>(inst.operands.at(1)),
std::get<uint32_t>(inst.operands.at(2)));
trace_builder.op_jumpi(std::get<uint8_t>(inst.operands.at(0)),
std::get<uint32_t>(inst.operands.at(1)),
std::get<uint32_t>(inst.operands.at(2)));
break;
case OpCode::INTERNALCALL:
trace_builder.internal_call(std::get<uint32_t>(inst.operands.at(0)));
trace_builder.op_internal_call(std::get<uint32_t>(inst.operands.at(0)));
break;
case OpCode::INTERNALRETURN:
trace_builder.internal_return();
trace_builder.op_internal_return();
break;
// Machine State - Memory
case OpCode::SET: {
Expand Down Expand Up @@ -599,7 +599,7 @@ std::vector<Row> Execution::gen_trace(std::vector<Instruction> const& instructio
break;
// Control Flow - Contract Calls
case OpCode::RETURN: {
auto ret = trace_builder.return_op(std::get<uint8_t>(inst.operands.at(0)),
auto ret = trace_builder.op_return(std::get<uint8_t>(inst.operands.at(0)),
std::get<uint32_t>(inst.operands.at(1)),
std::get<uint32_t>(inst.operands.at(2)));
returndata.insert(returndata.end(), ret.begin(), ret.end());
Expand All @@ -609,7 +609,7 @@ std::vector<Row> Execution::gen_trace(std::vector<Instruction> const& instructio
case OpCode::DEBUGLOG:
// We want a noop, but we need to execute something that both advances the PC,
// and adds a valid row to the trace.
trace_builder.jump(pc + 1);
trace_builder.op_jump(pc + 1);
break;
case OpCode::CALL:
trace_builder.op_call(std::get<uint8_t>(inst.operands.at(0)),
Expand Down
14 changes: 7 additions & 7 deletions barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_trace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1888,7 +1888,7 @@ void AvmTraceBuilder::op_div(
* @param dst_offset The starting index of memory where calldata will be copied to.
* @param call_data_mem The vector containing calldata.
*/
void AvmTraceBuilder::calldata_copy(
void AvmTraceBuilder::op_calldata_copy(
uint8_t indirect, uint32_t cd_offset, uint32_t copy_size, uint32_t dst_offset, std::vector<FF> const& call_data_mem)
{
// We parallelize storing memory operations in chunk of 3, i.e., 1 per intermediate register.
Expand Down Expand Up @@ -1998,7 +1998,7 @@ void AvmTraceBuilder::calldata_copy(
// Credit to SEAN for coming up with this revert opcode
std::vector<FF> AvmTraceBuilder::op_revert(uint8_t indirect, uint32_t ret_offset, uint32_t ret_size)
{
return return_op(indirect, ret_offset, ret_size);
return op_return(indirect, ret_offset, ret_size);
}

/**
Expand All @@ -2016,7 +2016,7 @@ std::vector<FF> AvmTraceBuilder::op_revert(uint8_t indirect, uint32_t ret_offset
* @param ret_size The number of elements to be returned.
* @return The returned memory region as a std::vector.
*/
std::vector<FF> AvmTraceBuilder::return_op(uint8_t indirect, uint32_t ret_offset, uint32_t ret_size)
std::vector<FF> AvmTraceBuilder::op_return(uint8_t indirect, uint32_t ret_offset, uint32_t ret_size)
{
if (ret_size == 0) {
halt();
Expand Down Expand Up @@ -2212,7 +2212,7 @@ void AvmTraceBuilder::op_dagasleft(uint8_t indirect, uint32_t dst_offset)
*
* @param jmp_dest - The destination to jump to
*/
void AvmTraceBuilder::jump(uint32_t jmp_dest)
void AvmTraceBuilder::op_jump(uint32_t jmp_dest)
{
auto clk = static_cast<uint32_t>(main_trace.size()) + 1;

Expand Down Expand Up @@ -2242,7 +2242,7 @@ void AvmTraceBuilder::jump(uint32_t jmp_dest)
* @param jmp_dest The destination to jump to
* @param cond_offset Offset of the condition
*/
void AvmTraceBuilder::jumpi(uint8_t indirect, uint32_t jmp_dest, uint32_t cond_offset)
void AvmTraceBuilder::op_jumpi(uint8_t indirect, uint32_t jmp_dest, uint32_t cond_offset)
{
auto clk = static_cast<uint32_t>(main_trace.size()) + 1;

Expand Down Expand Up @@ -2304,7 +2304,7 @@ void AvmTraceBuilder::jumpi(uint8_t indirect, uint32_t jmp_dest, uint32_t cond_o
*
* @param jmp_dest - The destination to jump to
*/
void AvmTraceBuilder::internal_call(uint32_t jmp_dest)
void AvmTraceBuilder::op_internal_call(uint32_t jmp_dest)
{
auto clk = static_cast<uint32_t>(main_trace.size()) + 1;

Expand Down Expand Up @@ -2350,7 +2350,7 @@ void AvmTraceBuilder::internal_call(uint32_t jmp_dest)
* TODO(https://github.com/AztecProtocol/aztec-packages/issues/3740): This function MUST come after a call
* instruction.
*/
void AvmTraceBuilder::internal_return()
void AvmTraceBuilder::op_internal_return()
{
auto clk = static_cast<uint32_t>(main_trace.size()) + 1;

Expand Down
20 changes: 10 additions & 10 deletions barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_trace.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,36 +140,36 @@ class AvmTraceBuilder {
void op_dagasleft(uint8_t indirect, uint32_t dst_offset);

// Jump to a given program counter.
void jump(uint32_t jmp_dest);
void op_jump(uint32_t jmp_dest);

// Jump conditionally to a given program counter.
void jumpi(uint8_t indirect, uint32_t jmp_dest, uint32_t cond_offset);
void op_jumpi(uint8_t indirect, uint32_t jmp_dest, uint32_t cond_offset);

// Jump to a given program counter; storing the return location on a call stack.
// TODO(md): this program counter MUST be an operand to the OPCODE.
void internal_call(uint32_t jmp_dest);
void op_internal_call(uint32_t jmp_dest);

// Return from a jump.
void internal_return();
void op_internal_return();

// Halt -> stop program execution.
void halt();

// CALLDATACOPY opcode with direct/indirect memory access, i.e.,
// direct: M[dst_offset:dst_offset+copy_size] = calldata[cd_offset:cd_offset+copy_size]
// indirect: M[M[dst_offset]:M[dst_offset]+copy_size] = calldata[cd_offset:cd_offset+copy_size]
void calldata_copy(uint8_t indirect,
uint32_t cd_offset,
uint32_t copy_size,
uint32_t dst_offset,
std::vector<FF> const& call_data_mem);
void op_calldata_copy(uint8_t indirect,
uint32_t cd_offset,
uint32_t copy_size,
uint32_t dst_offset,
std::vector<FF> const& call_data_mem);

// REVERT Opcode (that just call return under the hood for now)
std::vector<FF> op_revert(uint8_t indirect, uint32_t ret_offset, uint32_t ret_size);
// RETURN opcode with direct and indirect memory access, i.e.,
// direct: return(M[ret_offset:ret_offset+ret_size])
// indirect: return(M[M[ret_offset]:M[ret_offset]+ret_size])
std::vector<FF> return_op(uint8_t indirect, uint32_t ret_offset, uint32_t ret_size);
std::vector<FF> op_return(uint8_t indirect, uint32_t ret_offset, uint32_t ret_size);

// Calls
void op_call(uint8_t indirect,
Expand Down
Loading
Loading