if (!EM_open((char*) inputfilename))
fatal("couldn't open input '%s': %s",
inputfilename ? inputfilename : "<stdin>", EM_error);
-
+
if (outputfilename)
{
outputfile = fopen(outputfilename, "w");
static void constrain_output_reg_equal_to(int child)
{
struct value* value = find_value_of_child(child);
- pmap_add(¤t_hop->equals_constraint, ¤t_hop->value, value);
+ pmap_add(¤t_hop->equals_constraint, ¤t_insn->value, value);
}
static const struct burm_emitter_data emitter_data =
switch (node->label)
{
case ir_to_esn(IR_REG, 0):
- hop_add_move(current_hop, &node->ir->value, current_hop->value);
+ if (current_hop->insels.count == 0)
+ hop_add_move(current_hop, &node->ir->value, current_hop->value);
break;
case ir_to_esn(IR_NOP, 'I'):
if (hop->is_move && invreg1 && outvreg1)
graph_add_edge(&affinity, invreg1, outvreg1);
}
+
+ /* Ensure that registers which are constrained to be in the same hreg for input
+ * and output are coalesced. */
+
+ for (k=0; k<hop->equals_constraint.count; k++)
+ {
+ struct value* left = hop->equals_constraint.item[k].left;
+ struct value* right = hop->equals_constraint.item[k].right;
+ struct vreg* leftvreg = actual(hop_find_output_vreg(hop, left));
+ struct vreg* rightvreg = actual(hop_find_input_vreg(hop, right));
+ coalesce(leftvreg, rightvreg);
+ }
}
}
}
void procedure_compile(struct procedure* proc)
{
current_proc = proc;
+ tracef('P', "P: compiling %s\n", proc->name);
pass_group_irs();
print_blocks('a');