Commit 4024886a authored by Christoph Mallon's avatar Christoph Mallon
Browse files

arm: Match positive and negative immediates for Cmp (negative uses Cmn).

parent 7a5a2923
......@@ -447,7 +447,7 @@ static void emit_arm_B(const ir_node *irn)
}
ir_node *const op1 = get_irn_n(irn, n_arm_B_flags);
assert(is_arm_Cmp(op1) || is_arm_Tst(op1));
assert(is_arm_Cmn(op1) || is_arm_Cmp(op1) || is_arm_Tst(op1));
arm_cmp_attr_t const *const cmp_attr = get_arm_cmp_attr_const(op1);
......
......@@ -45,12 +45,13 @@ static bool has_shifter_operand(const ir_node *node)
return is_arm_Add(node) || is_arm_And(node) || is_arm_Or(node)
|| is_arm_Eor(node) || is_arm_Bic(node) || is_arm_Sub(node)
|| is_arm_Rsb(node) || is_arm_Mov(node) || is_arm_Mvn(node)
|| is_arm_Cmp(node) || is_arm_Tst(node) || is_arm_LinkMovPC(node);
|| is_arm_Cmn(node) || is_arm_Cmp(node) || is_arm_Tst(node)
|| is_arm_LinkMovPC(node);
}
static bool has_cmp_attr(const ir_node *node)
{
return is_arm_Cmp(node) || is_arm_Tst(node);
return is_arm_Cmn(node) || is_arm_Cmp(node) || is_arm_Tst(node);
}
static bool has_farith_attr(const ir_node *node)
......
......@@ -481,6 +481,11 @@ Address => {
mode => $mode_gp,
},
Cmn => {
template => $cmp_shifter_operand,
emit => 'cmn %S0, %O',
},
Cmp => {
template => $cmp_shifter_operand,
emit => 'cmp %S0, %O',
......
......@@ -1205,10 +1205,19 @@ static ir_node *gen_Cmp(ir_node *node)
/* integer compare, TODO: use shifter_op in all its combinations */
ir_node *new_op1 = be_transform_node(op1);
new_op1 = gen_extension(dbgi, block, new_op1, cmp_mode);
ir_node *new_op2 = be_transform_node(op2);
new_op2 = gen_extension(dbgi, block, new_op2, cmp_mode);
return new_bd_arm_Cmp_reg(dbgi, block, new_op1, new_op2, false,
is_unsigned);
arm_immediate_t imm;
switch (try_encode_as_immediate(op2, &imm, IMM_POS | IMM_NEG)) {
case IMM_POS:
return new_bd_arm_Cmp_imm(dbgi, block, new_op1, imm.imm_8, imm.rot, false, is_unsigned);
case IMM_NEG:
return new_bd_arm_Cmn_imm(dbgi, block, new_op1, imm.imm_8, imm.rot, false, is_unsigned);
default: {
ir_node *new_op2 = be_transform_node(op2);
new_op2 = gen_extension(dbgi, block, new_op2, cmp_mode);
return new_bd_arm_Cmp_reg(dbgi, block, new_op1, new_op2, false, is_unsigned);
}
}
}
static ir_node *gen_Cond(ir_node *node)
......
Supports Markdown
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