From ee9e2d30505a2baa634cdb13c15443e1a4be1881 Mon Sep 17 00:00:00 2001 From: Max Wash Date: Sat, 17 Jan 2026 10:31:08 +0000 Subject: [PATCH] mie: arith: implement op printer callbacks --- mie/dialect/arith/op/addf.c | 16 +++++++++++++--- mie/dialect/arith/op/addi.c | 16 ++++++++++++++++ 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/mie/dialect/arith/op/addf.c b/mie/dialect/arith/op/addf.c index 5e695e2..44a990e 100644 --- a/mie/dialect/arith/op/addf.c +++ b/mie/dialect/arith/op/addf.c @@ -6,9 +6,19 @@ static enum mie_status print(struct mie_printer *printer, const struct mie_op *op) { - const struct mie_attribute *sym_name - = mie_attribute_map_get(&op->op_attrib, "sym_name"); - b_stream_write_fmt(printer->p_stream, NULL, " @%s", NULL); + if (MIE_VECTOR_COUNT(op->op_args) != 2) { + return MIE_SUCCESS; + } + + const struct mie_op_arg *left = &op->op_args.items[0]; + const struct mie_op_arg *right = &op->op_args.items[1]; + + b_stream_write_char(printer->p_stream, ' '); + mie_printer_print_op_arg(printer, left, false); + b_stream_write_string(printer->p_stream, ", ", NULL); + mie_printer_print_op_arg(printer, right, false); + b_stream_write_string(printer->p_stream, " : ", NULL); + mie_printer_print_type(printer, mie_op_arg_get_type(left)); return MIE_SUCCESS; } diff --git a/mie/dialect/arith/op/addi.c b/mie/dialect/arith/op/addi.c index 25f4204..62770e8 100644 --- a/mie/dialect/arith/op/addi.c +++ b/mie/dialect/arith/op/addi.c @@ -1,9 +1,25 @@ #include #include +#include #include +#include static enum mie_status print(struct mie_printer *printer, const struct mie_op *op) { + if (MIE_VECTOR_COUNT(op->op_args) != 2) { + return MIE_SUCCESS; + } + + const struct mie_op_arg *left = &op->op_args.items[0]; + const struct mie_op_arg *right = &op->op_args.items[1]; + + b_stream_write_char(printer->p_stream, ' '); + mie_printer_print_op_arg(printer, left, false); + b_stream_write_string(printer->p_stream, ", ", NULL); + mie_printer_print_op_arg(printer, right, false); + b_stream_write_string(printer->p_stream, " : ", NULL); + mie_printer_print_type(printer, mie_op_arg_get_type(left)); + return MIE_SUCCESS; }