mie: re-implement vectors of blocks and registers using vector move callbacks
vector move callbacks allow mie_name instances to be stored in movable memory, as the internal bst pointers can now be fixed during vector resize operations.
This commit is contained in:
@@ -1,8 +1,29 @@
|
||||
#include <assert.h>
|
||||
#include <mie/ir/block.h>
|
||||
#include <mie/ir/op.h>
|
||||
#include <mie/ir/register.h>
|
||||
#include <mie/print/printer.h>
|
||||
|
||||
static enum mie_status cleanup(void *p)
|
||||
{
|
||||
return MIE_SUCCESS;
|
||||
}
|
||||
|
||||
static enum mie_status move(void *dst, void *src, size_t itemsz)
|
||||
{
|
||||
assert(itemsz == sizeof(struct mie_block));
|
||||
struct mie_block *dest_block = dst, *src_block = src;
|
||||
memmove(dest_block, src_block, sizeof *src_block);
|
||||
mie_name_move(&dest_block->b_name, &src_block->b_name);
|
||||
|
||||
return MIE_SUCCESS;
|
||||
}
|
||||
|
||||
struct mie_vector_ops mie_block_vector_ops = {
|
||||
.v_destroy = cleanup,
|
||||
.v_move = move,
|
||||
};
|
||||
|
||||
static void print_block_header_params(
|
||||
struct mie_printer *printer, const struct mie_block *block)
|
||||
{
|
||||
@@ -17,11 +38,11 @@ static void print_block_header_params(
|
||||
b_stream_write_string(printer->p_stream, ", ", NULL);
|
||||
}
|
||||
|
||||
mie_printer_print_register(printer, block->b_params.items[i], 0);
|
||||
mie_printer_print_register(printer, &block->b_params.items[i], 0);
|
||||
|
||||
b_stream_write_string(printer->p_stream, ": ", NULL);
|
||||
|
||||
mie_printer_print_type(printer, block->b_params.items[i]->reg_type);
|
||||
mie_printer_print_type(printer, block->b_params.items[i].reg_type);
|
||||
}
|
||||
|
||||
b_stream_write_char(printer->p_stream, ')');
|
||||
|
||||
@@ -179,7 +179,7 @@ static void print_type_signature(
|
||||
b_stream_write_string(printer->p_stream, ", ", NULL);
|
||||
}
|
||||
|
||||
type = op->op_result.items[i]->reg_type;
|
||||
type = op->op_result.items[i].reg_type;
|
||||
mie_printer_print_type(printer, type);
|
||||
}
|
||||
|
||||
@@ -225,7 +225,7 @@ void mie_printer_print_op(struct mie_printer *printer, const struct mie_op *op)
|
||||
b_stream_write_string(printer->p_stream, ", ", NULL);
|
||||
}
|
||||
|
||||
mie_printer_print_register(printer, op->op_result.items[i], 0);
|
||||
mie_printer_print_register(printer, &op->op_result.items[i], 0);
|
||||
}
|
||||
|
||||
if (MIE_VECTOR_COUNT(op->op_result) > 0) {
|
||||
|
||||
@@ -15,7 +15,7 @@ void mie_printer_print_region(
|
||||
block_flags = MIE_PRINT_F_EXCLUDE_BLOCK_HEADER;
|
||||
}
|
||||
|
||||
const struct mie_block *block = region->r_blocks.items[i];
|
||||
const struct mie_block *block = ®ion->r_blocks.items[i];
|
||||
mie_printer_print_block(printer, block, block_flags);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user