mie: implement sub/mul/div instruction generation

This commit is contained in:
2025-04-14 20:14:28 +01:00
parent 7d619f7ea7
commit 7eae0557af
2 changed files with 124 additions and 9 deletions

View File

@@ -382,15 +382,33 @@ static b_status write_instr(
write_operand(converter, op->op_right, 0);
break;
}
case MIE_INSTR_SUB:
write_string(converter, "sub");
case MIE_INSTR_SUB: {
struct mie_binary_op *op = (struct mie_binary_op *)instr;
mie_type_to_string(op->op_type, type, sizeof type);
write_string_f(converter, "sub %s ", type);
write_operand(converter, op->op_left, 0);
write_string(converter, ", ");
write_operand(converter, op->op_right, 0);
break;
case MIE_INSTR_MUL:
write_string(converter, "mul");
}
case MIE_INSTR_MUL: {
struct mie_binary_op *op = (struct mie_binary_op *)instr;
mie_type_to_string(op->op_type, type, sizeof type);
write_string_f(converter, "mul %s ", type);
write_operand(converter, op->op_left, 0);
write_string(converter, ", ");
write_operand(converter, op->op_right, 0);
break;
case MIE_INSTR_DIV:
write_string(converter, "div");
}
case MIE_INSTR_DIV: {
struct mie_binary_op *op = (struct mie_binary_op *)instr;
mie_type_to_string(op->op_type, type, sizeof type);
write_string_f(converter, "div %s ", type);
write_operand(converter, op->op_left, 0);
write_string(converter, ", ");
write_operand(converter, op->op_right, 0);
break;
}
case MIE_INSTR_LOAD: {
struct mie_load *load = (struct mie_load *)instr;
mie_type_to_string(load->l_type, type, sizeof type);