Commit 3807f353 authored by Matthias Braun's avatar Matthias Braun
Browse files

arm: for shifter operands specify the first input number

parent 7026a4b5
......@@ -166,7 +166,7 @@ static void arm_emit_shifter_operand(const ir_node *node)
switch (attr->shift_modifier) {
case ARM_SHF_REG:
arm_emit_source_register(node, get_irn_arity(node) - 1);
arm_emit_source_register(node, attr->shifter_op_input);
return;
case ARM_SHF_IMM: {
unsigned val = attr->immediate_value;
......@@ -180,7 +180,7 @@ static void arm_emit_shifter_operand(const ir_node *node)
case ARM_SHF_LSL_IMM:
case ARM_SHF_LSR_IMM:
case ARM_SHF_ROR_IMM:
arm_emit_source_register(node, get_irn_arity(node) - 1);
arm_emit_source_register(node, attr->shifter_op_input);
be_emit_cstring(", ");
emit_shf_mod_name(attr->shift_modifier);
be_emit_irprintf(" #0x%X", attr->shift_immediate);
......@@ -190,15 +190,15 @@ static void arm_emit_shifter_operand(const ir_node *node)
case ARM_SHF_LSL_REG:
case ARM_SHF_LSR_REG:
case ARM_SHF_ROR_REG:
arm_emit_source_register(node, get_irn_arity(node) - 2);
arm_emit_source_register(node, attr->shifter_op_input);
be_emit_cstring(", ");
emit_shf_mod_name(attr->shift_modifier);
be_emit_cstring(" ");
arm_emit_source_register(node, get_irn_arity(node) - 1);
arm_emit_source_register(node, attr->shifter_op_input+1);
return;
case ARM_SHF_RRX:
arm_emit_source_register(node, get_irn_arity(node) - 1);
arm_emit_source_register(node, attr->shifter_op_input);
panic("RRX shifter emitter TODO");
case ARM_SHF_INVALID:
......
......@@ -316,14 +316,16 @@ static void init_arm_load_store_attributes(ir_node *res, ir_mode *ls_mode,
attr->base.is_load_store = true;
}
static void init_arm_shifter_operand(ir_node *res, unsigned immediate_value,
static void init_arm_shifter_operand(ir_node *res, unsigned shifter_op_input,
unsigned immediate_value,
arm_shift_modifier_t shift_modifier,
unsigned shift_immediate)
{
arm_shifter_operand_t *attr = get_arm_shifter_operand_attr(res);
attr->immediate_value = immediate_value;
attr->shift_modifier = shift_modifier;
attr->shift_immediate = shift_immediate;
attr->immediate_value = immediate_value;
attr->shifter_op_input = shifter_op_input;
attr->shift_modifier = shift_modifier;
attr->shift_immediate = shift_immediate;
}
static void init_arm_cmp_attr(ir_node *res, bool ins_permuted, bool is_unsigned)
......
......@@ -64,6 +64,7 @@ typedef struct arm_attr_t {
typedef struct arm_shifter_operand_t {
arm_attr_t base;
arm_shift_modifier_t shift_modifier;
uint8_t shifter_op_input;
uint8_t immediate_value;
uint8_t shift_immediate;
} arm_shifter_operand_t;
......
......@@ -90,21 +90,21 @@ $default_copy_attr = "arm_copy_attr";
my %unop_shifter_operand_constructors = (
imm => {
attr => "unsigned char immediate_value, unsigned char immediate_rot",
custominit => "init_arm_shifter_operand(res, immediate_value, ARM_SHF_IMM, immediate_rot);",
custominit => "init_arm_shifter_operand(res, 0, immediate_value, ARM_SHF_IMM, immediate_rot);",
reg_req => { in => [], out => [ "gp" ] },
},
reg => {
custominit => "init_arm_shifter_operand(res, 0, ARM_SHF_REG, 0);",
custominit => "init_arm_shifter_operand(res, 0, 0, ARM_SHF_REG, 0);",
reg_req => { in => [ "gp" ], out => [ "gp" ] },
},
reg_shift_reg => {
attr => "arm_shift_modifier_t shift_modifier",
custominit => "init_arm_shifter_operand(res, 0, shift_modifier, 0);",
custominit => "init_arm_shifter_operand(res, 0, 0, shift_modifier, 0);",
reg_req => { in => [ "gp", "gp" ], out => [ "gp" ] },
},
reg_shift_imm => {
attr => "arm_shift_modifier_t shift_modifier, unsigned shift_immediate",
custominit => "init_arm_shifter_operand(res, 0, shift_modifier, shift_immediate);",
custominit => "init_arm_shifter_operand(res, 0, 0, shift_modifier, shift_immediate);",
reg_req => { in => [ "gp" ], out => [ "gp" ] },
},
);
......@@ -112,24 +112,24 @@ my %unop_shifter_operand_constructors = (
my %binop_shifter_operand_constructors = (
imm => {
attr => "unsigned char immediate_value, unsigned char immediate_rot",
custominit => "init_arm_shifter_operand(res, immediate_value, ARM_SHF_IMM, immediate_rot);",
custominit => "init_arm_shifter_operand(res, 1, immediate_value, ARM_SHF_IMM, immediate_rot);",
reg_req => { in => [ "gp" ], out => [ "gp" ] },
ins => [ "left" ],
},
reg => {
custominit => "init_arm_shifter_operand(res, 0, ARM_SHF_REG, 0);",
custominit => "init_arm_shifter_operand(res, 1, 0, ARM_SHF_REG, 0);",
reg_req => { in => [ "gp", "gp" ], out => [ "gp" ] },
ins => [ "left", "right" ],
},
reg_shift_reg => {
attr => "arm_shift_modifier_t shift_modifier",
custominit => "init_arm_shifter_operand(res, 0, shift_modifier, 0);",
custominit => "init_arm_shifter_operand(res, 1, 0, shift_modifier, 0);",
reg_req => { in => [ "gp", "gp", "gp" ], out => [ "gp" ] },
ins => [ "left", "right", "shift" ],
},
reg_shift_imm => {
attr => "arm_shift_modifier_t shift_modifier, unsigned shift_immediate",
custominit => "init_arm_shifter_operand(res, 0, shift_modifier, shift_immediate);",
custominit => "init_arm_shifter_operand(res, 1, 0, shift_modifier, shift_immediate);",
reg_req => { in => [ "gp", "gp" ], out => [ "gp" ] },
ins => [ "left", "right" ],
},
......@@ -139,7 +139,7 @@ my %cmp_shifter_operand_constructors = (
imm => {
attr => "unsigned char immediate_value, unsigned char immediate_rot, bool ins_permuted, bool is_unsigned",
custominit =>
"init_arm_shifter_operand(res, immediate_value, ARM_SHF_IMM, immediate_rot);\n".
"init_arm_shifter_operand(res, 1, immediate_value, ARM_SHF_IMM, immediate_rot);\n".
"\tinit_arm_cmp_attr(res, ins_permuted, is_unsigned);",
reg_req => { in => [ "gp" ], out => [ "flags" ] },
ins => [ "left" ],
......@@ -147,7 +147,7 @@ my %cmp_shifter_operand_constructors = (
reg => {
attr => "bool ins_permuted, bool is_unsigned",
custominit =>
"init_arm_shifter_operand(res, 0, ARM_SHF_REG, 0);\n".
"init_arm_shifter_operand(res, 1, 0, ARM_SHF_REG, 0);\n".
"\tinit_arm_cmp_attr(res, ins_permuted, is_unsigned);",
reg_req => { in => [ "gp", "gp" ], out => [ "flags" ] },
ins => [ "left", "right" ],
......@@ -155,7 +155,7 @@ my %cmp_shifter_operand_constructors = (
reg_shift_reg => {
attr => "arm_shift_modifier_t shift_modifier, bool ins_permuted, bool is_unsigned",
custominit =>
"init_arm_shifter_operand(res, 0, shift_modifier, 0);\n".
"init_arm_shifter_operand(res, 1, 0, shift_modifier, 0);\n".
"\tinit_arm_cmp_attr(res, ins_permuted, is_unsigned);",
reg_req => { in => [ "gp", "gp", "gp" ], out => [ "flags" ] },
ins => [ "left", "right", "shift" ],
......@@ -163,7 +163,7 @@ my %cmp_shifter_operand_constructors = (
reg_shift_imm => {
attr => "arm_shift_modifier_t shift_modifier, unsigned shift_immediate, bool ins_permuted, bool is_unsigned",
custominit =>
"init_arm_shifter_operand(res, 0, shift_modifier, shift_immediate);\n".
"init_arm_shifter_operand(res, 1, 0, shift_modifier, shift_immediate);\n".
"\tinit_arm_cmp_attr(res, ins_permuted, is_unsigned);",
reg_req => { in => [ "gp", "gp" ], out => [ "flags" ] },
ins => [ "left", "right" ],
......@@ -296,8 +296,8 @@ LinkMovPC => {
arity => "variable",
out_arity => "variable",
attr_type => "arm_shifter_operand_t",
attr => "arm_shift_modifier_t shift_modifier, unsigned char immediate_value, unsigned char immediate_rot",
custominit => "init_arm_shifter_operand(res, immediate_value, shift_modifier, immediate_rot);\n",
attr => "unsigned shiftop_input, arm_shift_modifier_t shift_modifier, unsigned char immediate_value, unsigned char immediate_rot",
custominit => "init_arm_shifter_operand(res, shiftop_input, immediate_value, shift_modifier, immediate_rot);\n",
emit => "mov lr, pc\n".
"mov pc, %O",
},
......
......@@ -1785,10 +1785,12 @@ static ir_node *gen_Call(ir_node *node)
}
/* TODO: use a generic address matcher here */
unsigned shiftop_input = 0;
if (is_Address(callee)) {
entity = get_Address_entity(callee);
} else {
/* TODO: finish load matcher here */
shiftop_input = in_arity;
in[in_arity] = be_transform_node(callee);
in_req[in_arity] = arm_reg_classes[CLASS_arm_gp].class_req;
++in_arity;
......@@ -1811,7 +1813,7 @@ static ir_node *gen_Call(ir_node *node)
* - we could also use LinkLdrPC
*/
res = new_bd_arm_LinkMovPC(dbgi, new_block, in_arity, in, out_arity,
ARM_SHF_REG, 0, 0);
shiftop_input, ARM_SHF_REG, 0, 0);
}
if (incsp != NULL) {
......
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