14void acir_roundtrip(
const std::filesystem::path& bytecode_path,
const std::filesystem::path& output_path)
18 BB_ASSERT(!
buf.empty(),
"acir_roundtrip: bytecode buffer is empty");
19 const uint8_t fmt =
buf[0];
21 "acir_roundtrip: expected msgpack format marker (2 or 3), got " +
std::to_string(fmt));
24 const char*
data =
reinterpret_cast<const char*
>(
buf.data() + 1);
25 size_t data_size =
buf.size() - 1;
26 auto oh = msgpack::unpack(
data, data_size);
34 }
catch (
const msgpack::type_error& e) {
35 std::cerr <<
"acir_roundtrip: failed to deserialize Program: " << e.what() <<
'\n';
43 msgpack::sbuffer sbuf;
44 msgpack::packer<msgpack::sbuffer> packer(sbuf);
48 std::vector<uint8_t> raw_bytes;
49 raw_bytes.push_back(fmt);
50 raw_bytes.insert(raw_bytes.end(), sbuf.data(), sbuf.data() + sbuf.size());
53 vinfo(
"acir_roundtrip: wrote roundtripped bytecode to ", output_path);
void acir_roundtrip(const std::filesystem::path &bytecode_path, const std::filesystem::path &output_path)
Deserialize an ACIR program from bytecode (msgpack), re-serialize it, and write the result to an outp...