diff --git a/m1/perf/sched.c b/m1/perf/sched.c index 877e2e8..9336d5c 100644 --- a/m1/perf/sched.c +++ b/m1/perf/sched.c @@ -22,7 +22,7 @@ #include #include #include -#include +//#include #include #include @@ -31,10 +31,15 @@ #include +#undef assert +#define assert(x) \ + do { if (!(x)) { printf("ASSERT: " #x "\n"); abort(); } } \ + while (0) //#define REG_STATS //#define LCPF /* longest critical path first */ +//#define DEBUG #ifdef DEBUG #define Dprintf printf #else @@ -447,13 +452,14 @@ static void unblock(struct insn *insn) } -static void put_reg_by_setter(struct insn *setter, int vm_reg) +static void put_reg_by_ref(struct data_ref *ref, int vm_reg) { + struct insn *setter = ref->dep; struct vm_reg *reg; if (setter) { put_reg(setter->vm_insn->dest); - if (setter->next_setter) + if (setter->next_setter && setter->next_setter != ref->insn) unblock(setter->next_setter); } else { reg = sc->regs+vm_reg2idx(vm_reg); @@ -483,15 +489,15 @@ static void issue(struct insn *insn, unsigned *code) switch (insn->arity) { case 3: - put_reg_by_setter(insn->cond.dep, FPVM_REG_IFB); + put_reg_by_ref(&insn->cond, FPVM_REG_IFB); /* fall through */ case 2: CODE(sc->cycle).opb = lookup_pfpu_reg(insn->vm_insn->opb); - put_reg_by_setter(insn->opb.dep, insn->vm_insn->opb); + put_reg_by_ref(&insn->opb, insn->vm_insn->opb); /* fall through */ case 1: CODE(sc->cycle).opa = lookup_pfpu_reg(insn->vm_insn->opa); - put_reg_by_setter(insn->opa.dep, insn->vm_insn->opa); + put_reg_by_ref(&insn->opa, insn->vm_insn->opa); break; case 0: break;