+ util_dynarray_fini(®s->regs[b].conflict_list);
+ }
+}
+
+void
+ra_set_serialize(const struct ra_regs *regs, struct blob *blob)
+{
+ blob_write_uint32(blob, regs->count);
+ blob_write_uint32(blob, regs->class_count);
+
+ for (unsigned int r = 0; r < regs->count; r++) {
+ struct ra_reg *reg = ®s->regs[r];
+ blob_write_bytes(blob, reg->conflicts, BITSET_WORDS(regs->count) *
+ sizeof(BITSET_WORD));
+ assert(util_dynarray_num_elements(®->conflict_list, unsigned int) == 0);
+ }
+
+ for (unsigned int c = 0; c < regs->class_count; c++) {
+ struct ra_class *class = regs->classes[c];
+ blob_write_bytes(blob, class->regs, BITSET_WORDS(regs->count) *
+ sizeof(BITSET_WORD));
+ blob_write_uint32(blob, class->p);
+ blob_write_bytes(blob, class->q, regs->class_count * sizeof(*class->q));
+ }
+
+ blob_write_uint32(blob, regs->round_robin);
+}
+
+struct ra_regs *
+ra_set_deserialize(void *mem_ctx, struct blob_reader *blob)
+{
+ unsigned int reg_count = blob_read_uint32(blob);
+ unsigned int class_count = blob_read_uint32(blob);
+
+ struct ra_regs *regs = ra_alloc_reg_set(mem_ctx, reg_count, false);
+ assert(regs->count == reg_count);
+
+ for (unsigned int r = 0; r < reg_count; r++) {
+ struct ra_reg *reg = ®s->regs[r];
+ blob_copy_bytes(blob, reg->conflicts, BITSET_WORDS(reg_count) *
+ sizeof(BITSET_WORD));