1
0
mirror of git://projects.qi-hardware.com/wernermisc.git synced 2024-11-15 11:36:15 +02:00

m1/perf/sched.c: code cleanup (no functional changes)

This commit is contained in:
Werner Almesberger 2011-09-26 17:22:02 -03:00
parent 24a9b85ce0
commit 35e99030e2

View File

@ -270,16 +270,19 @@ static int alloc_reg(struct insn *setter)
static void put_reg(int vm_reg) static void put_reg(int vm_reg)
{ {
int vm_idx; int vm_idx;
struct vm_reg *reg;
if (vm_reg >= 0) if (vm_reg >= 0)
return; return;
vm_idx = vm_reg2idx(vm_reg); vm_idx = vm_reg2idx(vm_reg);
assert(sc->regs[vm_idx].refs); reg = sc->regs+vm_idx;
if (--sc->regs[vm_idx].refs)
assert(reg->refs);
if (--reg->refs)
return; return;
Dprintf(" free reg %d\n", sc->regs[vm_idx].pfpu_reg); Dprintf(" free reg %d\n", reg->pfpu_reg);
#ifdef REG_STATS #ifdef REG_STATS
assert(sc->curr_regs); assert(sc->curr_regs);
@ -290,12 +293,11 @@ static void put_reg(int vm_reg)
* Prepend so that register numbers stay small and bugs reveal * Prepend so that register numbers stay small and bugs reveal
* themselves more rapidly. * themselves more rapidly.
*/ */
list_add(&sc->unallocated, list_add(&sc->unallocated, &sc->pfpu_regs[reg->pfpu_reg].more);
&sc->pfpu_regs[sc->regs[vm_idx].pfpu_reg].more);
/* clear it for style only */ /* clear it for style only */
sc->regs[vm_idx].setter = NULL; reg->setter = NULL;
sc->regs[vm_idx].pfpu_reg = 0; reg->pfpu_reg = 0;
} }
@ -317,13 +319,13 @@ static int init_registers(struct fpvm_fragment *frag,
{ {
int i; int i;
get_registers(frag, registers);
sc->regs = sc->regs =
calloc(frag->nbindings-frag->next_sur, sizeof(struct vm_reg)); calloc(frag->nbindings-frag->next_sur, sizeof(struct vm_reg));
if (!sc->regs) if (!sc->regs)
return -1; return -1;
get_registers(frag, registers);
for (i = 0; i != frag->ninstructions; i++) { for (i = 0; i != frag->ninstructions; i++) {
mark(frag->code[i].opa); mark(frag->code[i].opa);
mark(frag->code[i].opb); mark(frag->code[i].opb);
@ -377,7 +379,7 @@ static void init_scheduler(struct fpvm_fragment *frag)
list_init(&sc->unscheduled); list_init(&sc->unscheduled);
list_init(&sc->waiting); list_init(&sc->waiting);
for (i = 0; i != PFPU_PROGSIZE; i++) for (i = 0; i != PFPU_PROGSIZE; i++)
list_init(&sc->ready[i]); list_init(sc->ready+i);
for (i = 0; i != frag->ninstructions; i++) { for (i = 0; i != frag->ninstructions; i++) {
insn = sc->insns+i; insn = sc->insns+i;
@ -444,7 +446,7 @@ static void init_scheduler(struct fpvm_fragment *frag)
if (dep->insn->distance > insn->distance) if (dep->insn->distance > insn->distance)
insn->distance = dep->insn->distance; insn->distance = dep->insn->distance;
/* /*
* While it wold be more correct to add one for the cycle * While it would be more correct to add one for the cycle
* following the write cycle, this also has the effect of * following the write cycle, this also has the effect of
* producing slighly worse results on the example set of * producing slighly worse results on the example set of
* patches. Let's thus keep this "bug" for now. * patches. Let's thus keep this "bug" for now.
@ -571,7 +573,7 @@ static int schedule(unsigned int *code)
Dprintf("@%d --- remaining %d, waiting %d + ready %d\n", Dprintf("@%d --- remaining %d, waiting %d + ready %d\n",
i, remaining, count(&sc->waiting), count(&sc->ready[i])); i, remaining, count(&sc->waiting), count(&sc->ready[i]));
list_concat(&sc->waiting, &sc->ready[i]); list_concat(&sc->waiting, sc->ready+i);
best = NULL; best = NULL;
foreach (insn, &sc->waiting) { foreach (insn, &sc->waiting) {
end = i+insn->latency; end = i+insn->latency;