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: codegen acir opcodes after renaming arithmetic to assertzero #3896

Merged
merged 1 commit into from
Jan 9, 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
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ poly_triple serialize_arithmetic_gate(Circuit::Expression const& arg)
return pt;
}

void handle_arithmetic(Circuit::Opcode::Arithmetic const& arg, acir_format& af)
void handle_arithmetic(Circuit::Opcode::AssertZero const& arg, acir_format& af)
{
af.constraints.push_back(serialize_arithmetic_gate(arg.value));
}
Expand Down Expand Up @@ -269,7 +269,7 @@ acir_format circuit_buf_to_acir_format(std::vector<uint8_t> const& buf)
std::visit(
[&](auto&& arg) {
using T = std::decay_t<decltype(arg)>;
if constexpr (std::is_same_v<T, Circuit::Opcode::Arithmetic>) {
if constexpr (std::is_same_v<T, Circuit::Opcode::AssertZero>) {
handle_arithmetic(arg, af);
} else if constexpr (std::is_same_v<T, Circuit::Opcode::BlackBoxFuncCall>) {
handle_blackbox_func_call(arg, af);
Expand Down
24 changes: 12 additions & 12 deletions barretenberg/cpp/src/barretenberg/dsl/acir_format/serde/acir.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -805,12 +805,12 @@ struct MemOp {

struct Opcode {

struct Arithmetic {
struct AssertZero {
Circuit::Expression value;

friend bool operator==(const Arithmetic&, const Arithmetic&);
friend bool operator==(const AssertZero&, const AssertZero&);
std::vector<uint8_t> bincodeSerialize() const;
static Arithmetic bincodeDeserialize(std::vector<uint8_t>);
static AssertZero bincodeDeserialize(std::vector<uint8_t>);
};

struct BlackBoxFuncCall {
Expand Down Expand Up @@ -856,7 +856,7 @@ struct Opcode {
static MemoryInit bincodeDeserialize(std::vector<uint8_t>);
};

std::variant<Arithmetic, BlackBoxFuncCall, Directive, Brillig, MemoryOp, MemoryInit> value;
std::variant<AssertZero, BlackBoxFuncCall, Directive, Brillig, MemoryOp, MemoryInit> value;

friend bool operator==(const Opcode&, const Opcode&);
std::vector<uint8_t> bincodeSerialize() const;
Expand Down Expand Up @@ -5109,25 +5109,25 @@ Circuit::Opcode serde::Deserializable<Circuit::Opcode>::deserialize(Deserializer

namespace Circuit {

inline bool operator==(const Opcode::Arithmetic& lhs, const Opcode::Arithmetic& rhs)
inline bool operator==(const Opcode::AssertZero& lhs, const Opcode::AssertZero& rhs)
{
if (!(lhs.value == rhs.value)) {
return false;
}
return true;
}

inline std::vector<uint8_t> Opcode::Arithmetic::bincodeSerialize() const
inline std::vector<uint8_t> Opcode::AssertZero::bincodeSerialize() const
{
auto serializer = serde::BincodeSerializer();
serde::Serializable<Opcode::Arithmetic>::serialize(*this, serializer);
serde::Serializable<Opcode::AssertZero>::serialize(*this, serializer);
return std::move(serializer).bytes();
}

inline Opcode::Arithmetic Opcode::Arithmetic::bincodeDeserialize(std::vector<uint8_t> input)
inline Opcode::AssertZero Opcode::AssertZero::bincodeDeserialize(std::vector<uint8_t> input)
{
auto deserializer = serde::BincodeDeserializer(input);
auto value = serde::Deserializable<Opcode::Arithmetic>::deserialize(deserializer);
auto value = serde::Deserializable<Opcode::AssertZero>::deserialize(deserializer);
if (deserializer.get_buffer_offset() < input.size()) {
throw_or_abort("Some input bytes were not read");
}
Expand All @@ -5138,17 +5138,17 @@ inline Opcode::Arithmetic Opcode::Arithmetic::bincodeDeserialize(std::vector<uin

template <>
template <typename Serializer>
void serde::Serializable<Circuit::Opcode::Arithmetic>::serialize(const Circuit::Opcode::Arithmetic& obj,
void serde::Serializable<Circuit::Opcode::AssertZero>::serialize(const Circuit::Opcode::AssertZero& obj,
Serializer& serializer)
{
serde::Serializable<decltype(obj.value)>::serialize(obj.value, serializer);
}

template <>
template <typename Deserializer>
Circuit::Opcode::Arithmetic serde::Deserializable<Circuit::Opcode::Arithmetic>::deserialize(Deserializer& deserializer)
Circuit::Opcode::AssertZero serde::Deserializable<Circuit::Opcode::AssertZero>::deserialize(Deserializer& deserializer)
{
Circuit::Opcode::Arithmetic obj;
Circuit::Opcode::AssertZero obj;
obj.value = serde::Deserializable<decltype(obj.value)>::deserialize(deserializer);
return obj;
}
Expand Down