1
0
mirror of git://projects.qi-hardware.com/wernermisc.git synced 2025-01-19 02:21:05 +02:00

m1/perf/sched.c: light code cleanup

This commit is contained in:
Werner Almesberger 2011-09-21 17:53:13 -03:00
parent b177acd632
commit e98f08e857

View File

@ -298,23 +298,6 @@ static void put_reg(int vm_reg)
} }
static void unblock(struct insn *insn);
static void put_reg_by_setter(struct insn *setter, int vm_reg)
{
struct vm_reg *reg;
if (setter) {
put_reg(setter->vm_insn->dest);
if (setter->next_setter)
unblock(setter->next_setter);
} else {
reg = sc->regs+vm_reg2idx(vm_reg);
if (reg->first_setter && !reg->first_setter->rmw)
unblock(reg->first_setter);
}
}
static int lookup_pfpu_reg(int vm_reg) static int lookup_pfpu_reg(int vm_reg)
{ {
return vm_reg >= 0 ? vm_reg : sc->regs[vm_reg2idx(vm_reg)].pfpu_reg; return vm_reg >= 0 ? vm_reg : sc->regs[vm_reg2idx(vm_reg)].pfpu_reg;
@ -464,6 +447,22 @@ static void unblock(struct insn *insn)
} }
static void put_reg_by_setter(struct insn *setter, int vm_reg)
{
struct vm_reg *reg;
if (setter) {
put_reg(setter->vm_insn->dest);
if (setter->next_setter)
unblock(setter->next_setter);
} else {
reg = sc->regs+vm_reg2idx(vm_reg);
if (reg->first_setter && !reg->first_setter->rmw)
unblock(reg->first_setter);
}
}
static void unblock_after(struct insn *insn, int cycle) static void unblock_after(struct insn *insn, int cycle)
{ {
if (insn->earliest <= cycle) if (insn->earliest <= cycle)
@ -472,13 +471,13 @@ static void unblock_after(struct insn *insn, int cycle)
} }
static void issue(struct insn *insn, int cycle, unsigned *code) static void issue(struct insn *insn, unsigned *code)
{ {
struct data_ref *ref; struct data_ref *ref;
int end; int end;
end = cycle+insn->latency; end = sc->cycle+insn->latency;
Dprintf("cycle %d: insn %lu L %d (A %d B %d)\n", cycle, Dprintf("cycle %d: insn %lu L %d (A %d B %d)\n", sc->cycle,
insn-sc->insns, insn->latency, insn->vm_insn->opa, insn-sc->insns, insn->latency, insn->vm_insn->opa,
insn->vm_insn->opb); insn->vm_insn->opb);
@ -487,11 +486,11 @@ static void issue(struct insn *insn, int cycle, unsigned *code)
put_reg_by_setter(insn->cond.dep, FPVM_REG_IFB); put_reg_by_setter(insn->cond.dep, FPVM_REG_IFB);
/* fall through */ /* fall through */
case 2: case 2:
CODE(cycle).opb = lookup_pfpu_reg(insn->vm_insn->opb); 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_setter(insn->opb.dep, insn->vm_insn->opb);
/* fall through */ /* fall through */
case 1: case 1:
CODE(cycle).opa = lookup_pfpu_reg(insn->vm_insn->opa); 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_setter(insn->opa.dep, insn->vm_insn->opa);
break; break;
case 0: case 0:
@ -501,7 +500,7 @@ static void issue(struct insn *insn, int cycle, unsigned *code)
} }
CODE(end).dest = alloc_reg(insn); CODE(end).dest = alloc_reg(insn);
CODE(cycle).opcode = fpvm_to_pfpu(insn->vm_insn->opcode); CODE(sc->cycle).opcode = fpvm_to_pfpu(insn->vm_insn->opcode);
foreach (ref, &insn->dependants) foreach (ref, &insn->dependants)
unblock_after(ref->insn, end); unblock_after(ref->insn, end);
@ -555,7 +554,7 @@ static int schedule(unsigned int *code)
if (!best || best->distance < insn->distance) if (!best || best->distance < insn->distance)
best = insn; best = insn;
#else #else
issue(insn, i, code); issue(insn, code);
list_del(&insn->more); list_del(&insn->more);
remaining--; remaining--;
break; break;
@ -564,7 +563,7 @@ static int schedule(unsigned int *code)
} }
#ifdef LCPF #ifdef LCPF
if (best) { if (best) {
issue(best, i, code); issue(best, code);
list_del(&best->more); list_del(&best->more);
remaining--; remaining--;
} }