if (!insn->insndata->is_fragment)
{
+ struct value* firstchild = NULL;
insn->hop = current_hop = new_hop(current_bb, insn->ir);
current_hop->insndata = insn->insndata;
emit(insn);
+ if (insn->children[0])
+ {
+ if (insn->children[0]->hop)
+ firstchild = insn->children[0]->hop->value;
+ else
+ firstchild = &insn->children[0]->ir->value;
+ }
+
current_hop->value = &insn->value;
- switch (node->label)
+
+ if (insn_no == INSN_STMT)
+ {
+ tracef('I', "I: label=%d\n", node->label);
+ hop_get_value_usage(current_hop, firstchild)->input = true;
+ hop_get_value_usage(current_hop, current_hop->value)->output = true;
+ hop_add_insel(current_hop, "@copy %V %V", firstchild, current_hop->value);
+ }
+ else
{
- case ir_to_esn(IR_REG, 0):
- current_hop->value = &node->ir->value;
- break;
-
- case ir_to_esn(IR_NOP, 'I'):
- case ir_to_esn(IR_NOP, 'F'):
- case ir_to_esn(IR_NOP, 'L'):
- case ir_to_esn(IR_NOP, 'D'):
+ switch (node->label)
{
- struct insn* child = insn->children[0];
- struct value* value;
- if (child->hop)
- value = child->hop->value;
- else
- value = &child->ir->value;
-
- hop_get_value_usage(current_hop, value)->input = true;
- hop_get_value_usage(current_hop, current_hop->value)->output = true;
- hop_add_insel(current_hop, "@copy %V %V", value, current_hop->value);
- break;
+ case ir_to_esn(IR_REG, 0):
+ hop_get_value_usage(current_hop, &node->ir->value)->input = true;
+ hop_get_value_usage(current_hop, current_hop->value)->output = true;
+ hop_add_insel(current_hop, "@copy %V %V", &node->ir->value, current_hop->value);
+ break;
+
+ case ir_to_esn(IR_NOP, 'I'):
+ case ir_to_esn(IR_NOP, 'F'):
+ case ir_to_esn(IR_NOP, 'L'):
+ case ir_to_esn(IR_NOP, 'D'):
+ hop_get_value_usage(current_hop, firstchild)->input = true;
+ hop_get_value_usage(current_hop, current_hop->value)->output = true;
+ hop_add_insel(current_hop, "@copy %V %V", firstchild, current_hop->value);
+ break;
}
}
const static struct terminfo NOPL = { "NOP.L", NULL, NULL };
const static struct terminfo NOPD = { "NOP.D", NULL, NULL };
const static struct terminfo RET = { "RET", NULL, NULL };
+ Rule r;
nonterm("reg", true);
- rule(NULL, tree(®, NULL, NULL))->cost = 1;
+ r = rule(NULL, tree(®, NULL, NULL));
+ r->cost = 1;
+ assert(r->ern == INSN_STMT);
+
rule(®, tree(®, NULL, NULL))->cost = 1;
rule(®, tree(&NOPI, tree(®, NULL, NULL), NULL))->cost = 1;
rule(®, tree(&NOPF, tree(®, NULL, NULL), NULL))->cost = 1;