Bodge in enough phi support to let the instruction generator complete on basic

programs.
This commit is contained in:
David Given 2016-10-04 21:58:31 +02:00
parent 8d4186130d
commit c6f576f758
3 changed files with 25 additions and 7 deletions

View file

@ -12,6 +12,8 @@ struct basicblock
ARRAYOF(struct basicblock) nexts;
int order; /* used by SSA code */
ARRAYOF(struct vreg) liveins;
bool is_fake : 1;
bool is_root : 1;
bool is_terminated : 1;

View file

@ -191,15 +191,30 @@ static void select_instructions(void)
int insnno;
current_ir = current_bb->irs.item[i];
shadow = build_shadow_tree(current_ir, current_ir);
burm_label(shadow);
insnno = burm_rule(shadow->state_label, 1);
if (!insnno)
burm_panic_cannot_match(shadow);
if (current_ir->opcode == IR_PHI)
{
int j;
ir_print('I', current_ir);
walk_instructions(shadow, 1);
current_ir->result = new_vreg();
array_append(&current_bb->liveins, current_ir->result);
tracef('I', "I: %d is phi:", current_ir->result->id);
for (j=0; j<current_ir->u.phivalue.count; j++)
tracef('I', " $%d", current_ir->u.phivalue.item[j]->id);
tracef('I', "\n");
}
else
{
shadow = build_shadow_tree(current_ir, current_ir);
burm_label(shadow);
insnno = burm_rule(shadow->state_label, 1);
if (!insnno)
burm_panic_cannot_match(shadow);
ir_print('I', current_ir);
walk_instructions(shadow, 1);
}
}
}

View file

@ -62,6 +62,7 @@ PATTERNS
SETRET4(in:reg)
with ret reg
emit "mov r0, %in"
cost 4;
STACKADJUST4(delta:aluparam)