1
0
mirror of git://projects.qi-hardware.com/wernermisc.git synced 2025-01-18 21:41:07 +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)
{
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)
{
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;
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->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);
/* fall through */
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);
/* fall through */
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);
break;
case 0:
@ -501,7 +500,7 @@ static void issue(struct insn *insn, int cycle, unsigned *code)
}
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)
unblock_after(ref->insn, end);
@ -555,7 +554,7 @@ static int schedule(unsigned int *code)
if (!best || best->distance < insn->distance)
best = insn;
#else
issue(insn, i, code);
issue(insn, code);
list_del(&insn->more);
remaining--;
break;
@ -564,7 +563,7 @@ static int schedule(unsigned int *code)
}
#ifdef LCPF
if (best) {
issue(best, i, code);
issue(best, code);
list_del(&best->more);
remaining--;
}