diff --git a/m1/perf/sched.c b/m1/perf/sched.c index 8a371d6..52ea00c 100644 --- a/m1/perf/sched.c +++ b/m1/perf/sched.c @@ -244,7 +244,7 @@ static int alloc_reg(struct insn *setter) } else { reg = list_pop(&sc->unallocated); if (!reg) - abort(); + return -1; #ifdef REG_STATS sc->curr_regs++; @@ -495,10 +495,11 @@ static void unblock_after(struct insn *insn, int cycle) } -static void issue(struct insn *insn, unsigned *code) +static int issue(struct insn *insn, unsigned *code) { struct data_ref *ref; - int end; + int end, reg; + end = sc->cycle+insn->latency; Dprintf("cycle %d: insn %lu L %d (A %d B %d)\n", sc->cycle, @@ -523,7 +524,10 @@ static void issue(struct insn *insn, unsigned *code) abort(); } - CODE(end).dest = alloc_reg(insn); + reg = alloc_reg(insn); + if (reg < 0) + return -1; + CODE(end).dest = reg; CODE(sc->cycle).opcode = fpvm_to_pfpu(insn->vm_insn->opcode); foreach (ref, &insn->dependants) @@ -580,7 +584,8 @@ static int schedule(unsigned int *code) } } if (best) { - issue(best, code); + if (issue(best, code) < 0) + return -1; list_del(&best->more); remaining--; }