Line 19... |
Line 19... |
|
|
#include <stdio.h>
|
#include <stdio.h>
|
#include <stdlib.h>
|
#include <stdlib.h>
|
#include <stdarg.h>
|
#include <stdarg.h>
|
#include <assert.h>
|
#include <assert.h>
|
|
#include <string.h>
|
|
|
#include "sim-config.h"
|
#include "sim-config.h"
|
#include "abstract.h"
|
#include "abstract.h"
|
#include "cuc.h"
|
#include "cuc.h"
|
#include "insn.h"
|
#include "insn.h"
|
#include "support/profile.h"
|
#include "support/profile.h"
|
Line 42... |
Line 44... |
int i;
|
int i;
|
PRINTF ("------- %s -------\n", s);
|
PRINTF ("------- %s -------\n", s);
|
for (i = 0; i < f->num_bb; i++) {
|
for (i = 0; i < f->num_bb; i++) {
|
if (f->bb[i].insn) PRINTF ("\n---- BB%-2x * %x ---- ", i, f->bb[i].cnt);
|
if (f->bb[i].insn) PRINTF ("\n---- BB%-2x * %x ---- ", i, f->bb[i].cnt);
|
else PRINTF ("BB%-2x: %4x-%-4x", i, f->bb[i].first, f->bb[i].last);
|
else PRINTF ("BB%-2x: %4x-%-4x", i, f->bb[i].first, f->bb[i].last);
|
PRINTF (" type %02x tmp %i ", f->bb[i].type, f->bb[i].tmp);
|
PRINTF (" type %02lx tmp %i ", f->bb[i].type, f->bb[i].tmp);
|
PRINTF ("next "); print_bb_num (f->bb[i].next[0]);
|
PRINTF ("next "); print_bb_num (f->bb[i].next[0]);
|
PRINTF (" "); print_bb_num (f->bb[i].next[1]);
|
PRINTF (" "); print_bb_num (f->bb[i].next[1]);
|
PRINTF (" prev "); print_bb_num (f->bb[i].prev[0]);
|
PRINTF (" prev "); print_bb_num (f->bb[i].prev[0]);
|
PRINTF (" "); print_bb_num (f->bb[i].prev[1]);
|
PRINTF (" "); print_bb_num (f->bb[i].prev[1]);
|
PRINTF ("\n");
|
PRINTF ("\n");
|
Line 350... |
Line 352... |
cuc_insn *ii = &f->bb[i].insn[j];
|
cuc_insn *ii = &f->bb[i].insn[j];
|
if ((ii->index == II_CMOV || ii->index == II_ADD) && ii->type & IT_COND && ii->opt[0] & OPT_DEST) {
|
if ((ii->index == II_CMOV || ii->index == II_ADD) && ii->type & IT_COND && ii->opt[0] & OPT_DEST) {
|
k = 0;
|
k = 0;
|
assert (ii->opt[k] & OPT_REGISTER);
|
assert (ii->opt[k] & OPT_REGISTER);
|
if ((signed)ii->op[k] >= 0 && ii->op[k] != FLAG_REG && ii->op[k] != LRBB_REG) {
|
if ((signed)ii->op[k] >= 0 && ii->op[k] != FLAG_REG && ii->op[k] != LRBB_REG) {
|
cucdebug (1, "Invalid dest conditional type opt%x op%x\n", ii->opt[0], ii->op[0]);
|
cucdebug (1, "Invalid dest conditional type opt%x op%lx\n", ii->opt[0], ii->op[0]);
|
goto err;
|
goto err;
|
}
|
}
|
}
|
}
|
for (k = 0; k < MAX_OPERANDS; k++) {
|
for (k = 0; k < MAX_OPERANDS; k++) {
|
if (ii->opt[k] & OPT_REF) {
|
if (ii->opt[k] & OPT_REF) {
|
Line 887... |
Line 889... |
if (f->bb[i].prev[0] == f->bb[i].prev[1]) f->bb[i].prev[1] = -1;
|
if (f->bb[i].prev[0] == f->bb[i].prev[1]) f->bb[i].prev[1] = -1;
|
if (f->bb[i].next[0] == f->bb[i].next[1]) f->bb[i].next[1] = -1;
|
if (f->bb[i].next[0] == f->bb[i].next[1]) f->bb[i].next[1] = -1;
|
|
|
for (j = 0; j < f->bb[i].ninsn; j++)
|
for (j = 0; j < f->bb[i].ninsn; j++)
|
for (k = 0; k < MAX_OPERANDS; k++)
|
for (k = 0; k < MAX_OPERANDS; k++)
|
if (f->bb[i].insn[j].opt[k] & OPT_BB && (signed)f->bb[i].insn[j].op[k] >= 0) {
|
if ((f->bb[i].insn[j].opt[k] & OPT_BB) &&
|
|
((signed)f->bb[i].insn[j].op[k] >= 0)) {
|
if (f->bb[i].insn[j].op[k] != BBID_END)
|
if (f->bb[i].insn[j].op[k] != BBID_END)
|
assert ((f->bb[i].insn[j].op[k] = reloc[f->bb[i].insn[j].op[k]]) >= 0);
|
assert ((f->bb[i].insn[j].op[k] = reloc[f->bb[i].insn[j].op[k]]) >= 0);
|
} else if (f->bb[i].insn[j].opt[k] & OPT_REF) {
|
} else if (f->bb[i].insn[j].opt[k] & OPT_REF) {
|
int t = f->bb[i].insn[j].op[k];
|
int t = f->bb[i].insn[j].op[k];
|
assert (reloc[REF_BB(t)] >= 0);
|
assert (reloc[REF_BB(t)] >= 0);
|
Line 1036... |
Line 1039... |
/* Create references */
|
/* Create references */
|
for (i = 0; i < f->bb[b].ninsn; i++) {
|
for (i = 0; i < f->bb[b].ninsn; i++) {
|
int k;
|
int k;
|
/* Check for source operands first */
|
/* Check for source operands first */
|
for (k = 0; k < MAX_OPERANDS; k++) {
|
for (k = 0; k < MAX_OPERANDS; k++) {
|
if (!(f->bb[b].insn[i].opt[k] & OPT_DEST))
|
if (!(f->bb[b].insn[i].opt[k] & OPT_DEST)) {
|
if (f->bb[b].insn[i].opt[k] & OPT_REGISTER) {
|
if (f->bb[b].insn[i].opt[k] & OPT_REGISTER) {
|
int t = f->bb[b].last_used_reg[f->bb[b].insn[i].op[k]];
|
int t = f->bb[b].last_used_reg[f->bb[b].insn[i].op[k]];
|
|
|
if (f->bb[b].insn[i].op[k] == 0) { /* Convert r0 to const0 */
|
if (f->bb[b].insn[i].op[k] == 0) { /* Convert r0 to const0 */
|
f->bb[b].insn[i].opt[k] = OPT_CONST;
|
f->bb[b].insn[i].opt[k] = OPT_CONST;
|
Line 1054... |
Line 1057... |
} else if (f->bb[b].insn[i].opt[k] & OPT_REF) {
|
} else if (f->bb[b].insn[i].opt[k] & OPT_REF) {
|
//f->INSN(f->bb[b].insn[i].op[k]).op[0] = -1; /* Mark referenced */
|
//f->INSN(f->bb[b].insn[i].op[k]).op[0] = -1; /* Mark referenced */
|
f->INSN(f->bb[b].insn[i].op[k]).type &= ~IT_UNUSED;
|
f->INSN(f->bb[b].insn[i].op[k]).type &= ~IT_UNUSED;
|
}
|
}
|
}
|
}
|
|
}
|
|
|
/* Now check for destination operand(s) */
|
/* Now check for destination operand(s) */
|
for (k = 0; k < MAX_OPERANDS; k++) if (f->bb[b].insn[i].opt[k] & OPT_DEST)
|
for (k = 0; k < MAX_OPERANDS; k++) if (f->bb[b].insn[i].opt[k] & OPT_DEST)
|
if ((f->bb[b].insn[i].opt[k] & ~OPT_DEST) == OPT_REGISTER
|
if ((f->bb[b].insn[i].opt[k] & ~OPT_DEST) == OPT_REGISTER
|
&& (int)f->bb[b].insn[i].op[k] >= 0) {
|
&& (int)f->bb[b].insn[i].op[k] >= 0) {
|
int t = f->bb[b].last_used_reg[f->bb[b].insn[i].op[k]];
|
|
assert (f->bb[b].insn[i].op[k] != 0); /* r0 should never be dest */
|
assert (f->bb[b].insn[i].op[k] != 0); /* r0 should never be dest */
|
f->bb[b].last_used_reg[f->bb[b].insn[i].op[k]] = REF (b, i);
|
f->bb[b].last_used_reg[f->bb[b].insn[i].op[k]] = REF (b, i);
|
}
|
}
|
}
|
}
|
}
|
}
|
Line 1214... |
Line 1217... |
//PRINTF (" [%i] ", curbb);
|
//PRINTF (" [%i] ", curbb);
|
f->bb[curbb].cnt++;
|
f->bb[curbb].cnt++;
|
prevbb = curbb;
|
prevbb = curbb;
|
}
|
}
|
} else {
|
} else {
|
if (verify_memoryarea(buf[i].addr))
|
if (verify_memoryarea(buf[i].addr)) {
|
if (buf[i].type & MPROF_WRITE) mscnt++, mssum += cur_area->delayw;
|
if (buf[i].type & MPROF_WRITE) mscnt++, mssum += cur_area->delayw;
|
else mlcnt++, mlsum += cur_area->delayr;
|
else mlcnt++, mlsum += cur_area->delayr;
|
}
|
}
|
}
|
}
|
|
}
|
//PRINTF ("\n");
|
//PRINTF ("\n");
|
} while (r == bufsize);
|
} while (r == bufsize);
|
//PRINTF ("\n");
|
//PRINTF ("\n");
|
|
|
runtime.cuc.mdelay[0] = (1. * mlsum) / mlcnt;
|
runtime.cuc.mdelay[0] = (1. * mlsum) / mlcnt;
|
Line 1291... |
Line 1295... |
|
|
/* Preroll if type == 1 or unroll if type == 0 loop in BB b `ntimes' times and return
|
/* Preroll if type == 1 or unroll if type == 0 loop in BB b `ntimes' times and return
|
new function. Original function is unmodified. */
|
new function. Original function is unmodified. */
|
static cuc_func *roll_loop (cuc_func *f, int b, int ntimes, int type)
|
static cuc_func *roll_loop (cuc_func *f, int b, int ntimes, int type)
|
{
|
{
|
int b1, t, i, j, prevb, prevart_b;
|
int b1, t, i, prevb, prevart_b;
|
cuc_func *n = dup_func (f);
|
cuc_func *n = dup_func (f);
|
cuc_bb *ob = &f->bb[b];
|
cuc_bb *ob = &f->bb[b];
|
cuc_insn *ii;
|
cuc_insn *ii;
|
|
|
assert (ntimes > 1);
|
assert (ntimes > 1);
|
Line 1463... |
Line 1467... |
cuc_func *preunroll_loop (cuc_func *f, int b, int preroll, int unroll, char *bb_filename)
|
cuc_func *preunroll_loop (cuc_func *f, int b, int preroll, int unroll, char *bb_filename)
|
{
|
{
|
int b1, i;
|
int b1, i;
|
cuc_func *n, *t;
|
cuc_func *n, *t;
|
int *counts;
|
int *counts;
|
int *bb_reloc;
|
|
|
|
if (preroll > 1) {
|
if (preroll > 1) {
|
t = roll_loop (f, b, preroll, 1);
|
t = roll_loop (f, b, preroll, 1);
|
b1 = t->num_bb - 2;
|
b1 = t->num_bb - 2;
|
if (unroll > 1) {
|
if (unroll > 1) {
|