Commit 4801addd authored by Christoph Mallon's avatar Christoph Mallon
Browse files

mips: Handle lowering of 64 bit subtraction.

Now 'long long f(long long a, long long b) { return a - b; }' can be translated.
parent 78774391
......@@ -35,6 +35,28 @@ static void mips_lower_add64(ir_node *const node, ir_mode *const mode)
ir_set_dw_lowered(node, res_low, res_high);
}
static void mips_lower_sub64(ir_node *const node, ir_mode *const mode)
{
dbg_info *const dbg = get_irn_dbg_info(node);
ir_node *const block = get_nodes_block(node);
ir_node *const left = get_Sub_left(node);
ir_node *const right = get_Sub_right(node);
ir_node *const left_low = get_lowered_low(left);
ir_node *const left_high = get_lowered_high(left);
ir_node *const right_low = get_lowered_low(right);
ir_node *const right_high = get_lowered_high(right);
ir_node *const res_low = new_rd_Sub(dbg, block, left_low, right_low);
ir_node *const cmp_carry = new_rd_Cmp(dbg, block, res_low, left_low, ir_relation_greater);
ir_graph *const irg = get_irn_irg(node);
ir_node *const one = new_r_Const(irg, get_mode_one(mode));
ir_node *const zero = new_r_Const(irg, get_mode_null(mode));
ir_node *const carry = new_rd_Mux(dbg, block, cmp_carry, zero, one);
ir_node *const sum_high = new_rd_Sub(dbg, block, left_high, right_high);
ir_node *const res_high = new_rd_Sub(dbg, block, sum_high, carry);
ir_set_dw_lowered(node, res_low, res_high);
}
void mips_lower64(void)
{
ir_mode *const word_unsigned = mips_reg_classes[CLASS_mips_gp].mode;
......@@ -49,5 +71,6 @@ void mips_lower64(void)
ir_prepare_dw_lowering(&lower_dw_params);
ir_register_dw_lower_function(op_Add, mips_lower_add64);
ir_register_dw_lower_function(op_Sub, mips_lower_sub64);
ir_lower_dw_ops();
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment