From 35e99030e260fa3b4c617560178fb81a22ca65c5 Mon Sep 17 00:00:00 2001 From: Werner Almesberger Date: Mon, 26 Sep 2011 17:22:02 -0300 Subject: [PATCH] m1/perf/sched.c: code cleanup (no functional changes) --- m1/perf/sched.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/m1/perf/sched.c b/m1/perf/sched.c index 25d3aeb..6b00b3c 100644 --- a/m1/perf/sched.c +++ b/m1/perf/sched.c @@ -270,16 +270,19 @@ static int alloc_reg(struct insn *setter) static void put_reg(int vm_reg) { int vm_idx; + struct vm_reg *reg; if (vm_reg >= 0) return; vm_idx = vm_reg2idx(vm_reg); - assert(sc->regs[vm_idx].refs); - if (--sc->regs[vm_idx].refs) + reg = sc->regs+vm_idx; + + assert(reg->refs); + if (--reg->refs) return; - Dprintf(" free reg %d\n", sc->regs[vm_idx].pfpu_reg); + Dprintf(" free reg %d\n", reg->pfpu_reg); #ifdef REG_STATS 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 * themselves more rapidly. */ - list_add(&sc->unallocated, - &sc->pfpu_regs[sc->regs[vm_idx].pfpu_reg].more); + list_add(&sc->unallocated, &sc->pfpu_regs[reg->pfpu_reg].more); /* clear it for style only */ - sc->regs[vm_idx].setter = NULL; - sc->regs[vm_idx].pfpu_reg = 0; + reg->setter = NULL; + reg->pfpu_reg = 0; } @@ -317,13 +319,13 @@ static int init_registers(struct fpvm_fragment *frag, { int i; - get_registers(frag, registers); - sc->regs = calloc(frag->nbindings-frag->next_sur, sizeof(struct vm_reg)); if (!sc->regs) return -1; + get_registers(frag, registers); + for (i = 0; i != frag->ninstructions; i++) { mark(frag->code[i].opa); mark(frag->code[i].opb); @@ -377,7 +379,7 @@ static void init_scheduler(struct fpvm_fragment *frag) list_init(&sc->unscheduled); list_init(&sc->waiting); for (i = 0; i != PFPU_PROGSIZE; i++) - list_init(&sc->ready[i]); + list_init(sc->ready+i); for (i = 0; i != frag->ninstructions; i++) { insn = sc->insns+i; @@ -444,7 +446,7 @@ static void init_scheduler(struct fpvm_fragment *frag) if (dep->insn->distance > 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 * producing slighly worse results on the example set of * 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", 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; foreach (insn, &sc->waiting) { end = i+insn->latency;