mie: ir: Op->Region, Region->Block, and Block->Op lists are now b_queues rather than mie_vectors
this change has two key benefits:
1. we no longer need to allocate large contigious buffers for Regions with lots
of Blocks, or Blocks with lots of Ops.
2. this simplifies re-arranging, inserting, and moving parts of the IR structure.
This commit is contained in:
@@ -51,7 +51,8 @@ static void print_block_header_params(
|
||||
static void print_block_header(
|
||||
struct mie_printer *printer, const struct mie_block *block)
|
||||
{
|
||||
if (!block->b_name.n_str && !MIE_VECTOR_COUNT(block->b_params)) {
|
||||
bool first_block = b_queue_prev(&block->b_entry) == NULL;
|
||||
if (first_block && !block->b_name.n_str) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -76,10 +77,11 @@ void mie_printer_print_block(
|
||||
|
||||
b_stream_push_indent(printer->p_stream, 4);
|
||||
|
||||
for (size_t i = 0; i < MIE_VECTOR_COUNT(block->b_ops); i++) {
|
||||
const struct mie_op *op = &block->b_ops.items[i];
|
||||
struct mie_op *op = mie_block_get_first_op(block);
|
||||
while (op) {
|
||||
mie_printer_print_op(printer, op);
|
||||
b_stream_write_char(printer->p_stream, '\n');
|
||||
op = mie_block_get_next_op(block, op);
|
||||
}
|
||||
|
||||
b_stream_pop_indent(printer->p_stream);
|
||||
|
||||
@@ -96,18 +96,24 @@ static void print_successor_list(
|
||||
|
||||
static void print_region_list(struct mie_printer *printer, const struct mie_op *op)
|
||||
{
|
||||
if (!MIE_VECTOR_COUNT(op->op_regions)) {
|
||||
if (b_queue_empty(&op->op_regions)) {
|
||||
return;
|
||||
}
|
||||
|
||||
b_stream_write_string(printer->p_stream, " (", NULL);
|
||||
|
||||
for (size_t i = 0; i < MIE_VECTOR_COUNT(op->op_regions); i++) {
|
||||
struct mie_region *region = mie_op_get_first_region(op);
|
||||
size_t i = 0;
|
||||
|
||||
while (region) {
|
||||
if (i > 0) {
|
||||
b_stream_write_string(printer->p_stream, ", ", NULL);
|
||||
}
|
||||
|
||||
mie_printer_print_region(printer, &op->op_regions.items[i], 0);
|
||||
mie_printer_print_region(printer, region, 0);
|
||||
|
||||
region = mie_op_get_next_region(op, region);
|
||||
i++;
|
||||
}
|
||||
|
||||
b_stream_write_string(printer->p_stream, ")", NULL);
|
||||
|
||||
@@ -8,15 +8,20 @@ void mie_printer_print_region(
|
||||
{
|
||||
b_stream_write_string(printer->p_stream, "{\n", NULL);
|
||||
|
||||
for (size_t i = 0; i < MIE_VECTOR_COUNT(region->r_blocks); i++) {
|
||||
struct mie_block *block = mie_region_get_first_block(region);
|
||||
size_t i = 0;
|
||||
|
||||
while (block) {
|
||||
enum mie_print_flags block_flags = 0;
|
||||
|
||||
if ((flags & MIE_PRINT_F_EXCLUDE_FIRST_BLOCK_HEADER) && (i == 0)) {
|
||||
block_flags = MIE_PRINT_F_EXCLUDE_BLOCK_HEADER;
|
||||
}
|
||||
|
||||
const struct mie_block *block = ®ion->r_blocks.items[i];
|
||||
mie_printer_print_block(printer, block, block_flags);
|
||||
|
||||
block = mie_region_get_next_block(region, block);
|
||||
i++;
|
||||
}
|
||||
|
||||
b_stream_write_string(printer->p_stream, "}", NULL);
|
||||
|
||||
Reference in New Issue
Block a user