OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /
    from Rev 935 to Rev 936
    Reverse comparison

Rev 935 → Rev 936

/trunk/or1ksim/cuc/cuc.h
97,6 → 97,8
 
#define cucdebug(x,s...) {if ((x) <= cuc_debug) printf (s);}
 
#define CUC_WIDTH_ITERATIONS 1000
 
/* Options */
/* Whether we are debugging cuc (0-9) */
extern int cuc_debug;
148,6 → 150,7
dep_list *dep; /* instruction dependencies */
unsigned long insn; /* Instruction opcode */
char disasm[40]; /* disassembled string */
unsigned long max; /* max result value */
int tmp;
} cuc_insn;
 
294,4 → 297,8
 
/* Calculates facts, that are determined by conditionals */
void insert_conditional_facts (cuc_func *func);
 
/* Width optimization -- detect maximum values */
void detect_max_values (cuc_func *f);
 
#endif /* __DATAF_H__ */
/trunk/or1ksim/cuc/Makefile.in
107,7 → 107,7
noinst_LIBRARIES = libcuc.a
 
libcuc_a_SOURCES = cuc.c cuc.h load.c bb.c memory.c \
verilog.c timings.c insn.c insn.h
verilog.c timings.c insn.c insn.h adv.c
 
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_HEADER = ../config.h
121,7 → 121,7
LIBS = @LIBS@
libcuc_a_LIBADD =
libcuc_a_OBJECTS = cuc.o load.o bb.o memory.o verilog.o timings.o \
insn.o
insn.o adv.o
COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
CCLD = $(CC)
LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@
132,8 → 132,8
 
TAR = gtar
GZIP_ENV = --best
DEP_FILES = .deps/bb.P .deps/cuc.P .deps/insn.P .deps/load.P \
.deps/memory.P .deps/timings.P .deps/verilog.P
DEP_FILES = .deps/adv.P .deps/bb.P .deps/cuc.P .deps/insn.P \
.deps/load.P .deps/memory.P .deps/timings.P .deps/verilog.P
SOURCES = $(libcuc_a_SOURCES)
OBJECTS = $(libcuc_a_OBJECTS)
 
/trunk/or1ksim/cuc/bb.c
1503,138 → 1503,3
return n;
}
 
/* Marks successor of b with mask m */
static void mark_successors (cuc_func *f, int b, int m, int stopb)
{
if (b < 0 || b == BBID_END) return;
if (f->bb[b].tmp & m) return;
f->bb[b].tmp |= m;
/* mark stopb also; and stop searching -- we will gen new result in stopb */
if (b == stopb) return;
mark_successors (f, f->bb[b].next[0], m, stopb);
mark_successors (f, f->bb[b].next[1], m, stopb);
}
 
static unsigned long mask (unsigned long c)
{
if (c) return (1 << (log2 (c) + 1)) - 1;
else return 0;
}
 
/* Calculates facts, that are determined by conditionals */
void insert_conditional_facts (cuc_func *f)
{
int b, i, j;
int b1, i1, j1;
cuc_insn n[2];
for (b = 0; b < f->num_bb; b++) if (f->bb[b].ninsn > 0) {
cuc_insn *ii = &f->bb[b].insn[f->bb[b].ninsn - 1];
if (ii->type & IT_BRANCH && ii->opt[1] & OPT_REF && REF_BB(ii->op[1]) == b
&& f->INSN(ii->op[1]).opt[2] & OPT_CONST) {
int ok = 1;
unsigned long c = f->INSN(ii->op[1]).op[2];
int rref = f->INSN(ii->op[1]).op[1];
unsigned long r;
if (!(f->INSN(ii->op[1]).opt[1] & OPT_REF)) continue;
r = f->INSN(rref).op[0];
for (j = 0; j < 2; j++) {
change_insn_type (&n[j], II_ADD);
n[j].type = 0;
n[j].dep = NULL;
n[j].op[0] = r; n[j].opt[0] = OPT_REGISTER | OPT_DEST;
n[j].op[1] = 0; n[j].opt[1] = OPT_CONST;
n[j].op[2] = rref; n[j].opt[2] = OPT_REF;
n[j].opt[3] = OPT_NONE;
sprintf (n[j].disasm, "conditional %s fact", j ? "false" : "true");
}
/* First get the conditional and two instruction to place after the current BB */
switch (f->INSN(ii->op[1]).index) {
case II_SFEQ:
change_insn_type (&n[0], II_ADD);
n[0].op[0] = r; n[0].opt[0] = OPT_REGISTER | OPT_DEST;
n[0].op[1] = 0; n[0].opt[1] = OPT_CONST;
n[0].op[2] = c; n[0].opt[2] = OPT_CONST;
break;
case II_SFNE:
change_insn_type (&n[1], II_ADD);
n[1].op[0] = r; n[1].opt[0] = OPT_REGISTER | OPT_DEST;
n[1].op[1] = 0; n[1].opt[1] = OPT_CONST;
n[1].op[2] = c; n[1].opt[2] = OPT_CONST;
break;
case II_SFLT:
change_insn_type (&n[0], II_AND);
n[0].op[0] = r; n[0].opt[0] = OPT_REGISTER | OPT_DEST;
n[0].op[1] = rref; n[0].opt[1] = OPT_REF;
n[0].op[2] = mask (c); n[0].opt[2] = OPT_CONST;
break;
case II_SFGT:
change_insn_type (&n[1], II_ADD);
n[1].op[0] = r; n[1].opt[0] = OPT_REGISTER | OPT_DEST;
n[1].op[1] = rref; n[1].opt[1] = OPT_REF;
n[1].op[2] = mask (c + 1); n[1].opt[2] = OPT_CONST;
break;
case II_SFLE:
change_insn_type (&n[0], II_AND);
n[0].op[0] = r; n[0].opt[0] = OPT_REGISTER | OPT_DEST;
n[0].op[1] = rref; n[0].opt[1] = OPT_REF;
n[0].op[2] = mask (c); n[0].opt[2] = OPT_CONST;
break;
case II_SFGE:
change_insn_type (&n[1], II_ADD);
n[1].op[0] = r; n[1].opt[0] = OPT_REGISTER | OPT_DEST;
n[1].op[1] = rref; n[1].opt[1] = OPT_REF;
n[1].op[2] = mask (c + 1); n[1].opt[2] = OPT_CONST;
break;
default:
ok = 0;
break;
}
 
/* Now add two BBs at the end and relink */
if (ok) {
for (j = 0; j < 2; j++) {
int nb = f->num_bb++;
int sb;
assert (nb < MAX_BB);
f->bb[nb].type = 0;
f->bb[nb].first = -1; f->bb[nb].last = -1;
f->bb[nb].prev[0] = b; f->bb[nb].prev[1] = -1;
sb = f->bb[nb].next[0] = f->bb[b].next[j]; f->bb[nb].next[1] = -1;
printf ("%x %x %x\n", b, sb, nb);
assert (sb >= 0);
f->bb[b].next[j] = nb;
if (sb != BBID_END) {
if (f->bb[sb].prev[0] == b) f->bb[sb].prev[0] = nb;
else if (f->bb[sb].prev[1] == b) f->bb[sb].prev[1] = nb;
else assert (0);
}
f->bb[nb].insn = (cuc_insn *) malloc (sizeof (cuc_insn));
f->bb[nb].insn[0] = n[j];
f->bb[nb].ninsn = 1;
f->bb[nb].mdep = NULL;
f->bb[nb].nmemory = 0;
f->bb[nb].cnt = 0;
f->bb[nb].unrolled = 0;
f->bb[nb].ntim = 0;
f->bb[nb].selected_tim = -1;
}
for (b1 = 0; b1 < f->num_bb; b1++) f->bb[b1].tmp = 0;
/* Find successor blocks and change links accordingly */
mark_successors (f, f->num_bb - 2, 2, b);
mark_successors (f, f->num_bb - 1, 1, b);
for (b1 = 0; b1 < f->num_bb - 2; b1++) if (f->bb[b1].tmp == 1 || f->bb[b1].tmp == 2) {
int end;
if (REF_BB (rref) == b1) end = REF_I (rref);
else end = f->bb[b1].ninsn;
for (i1 = 0; i1 < end; i1++)
for (j1 = 0; j1 < MAX_OPERANDS; j1++)
if (f->bb[b1].insn[i1].opt[j1] & OPT_REF && f->bb[b1].insn[i1].op[j1] == rref)
f->bb[b1].insn[i1].op[j1] = REF (f->num_bb - f->bb[b1].tmp, 0);
}
print_cuc_bb (f, "FACT");
}
}
}
}
/trunk/or1ksim/cuc/insn.c
90,7 → 90,7
if (verbose) {
printf ("%-20s insn = %08x, index = %i, type = %04x ",
insn[i].disasm, insn[i].insn, insn[i].index, insn[i].type);
} else printf ("type = %04x ", insn[i].type);
} else printf ("max = %08x type = %04x ", insn[i].max, insn[i].type);
for (j = 0; j < MAX_OPERANDS; j++) {
if (insn[i].opt[j] & OPT_DEST) printf ("*");
switch (insn[i].opt[j] & ~OPT_DEST) {
/trunk/or1ksim/cuc/Makefile.am
21,5 → 21,5
noinst_LIBRARIES = libcuc.a
 
libcuc_a_SOURCES = cuc.c cuc.h load.c bb.c memory.c \
verilog.c timings.c insn.c insn.h
verilog.c timings.c insn.c insn.h adv.c
 
/trunk/or1ksim/cuc/cuc.c
56,6 → 56,7
void cuc_optimize (cuc_func *func)
{
int modified = 0;
int first = 1;
log ("Optimizing.\n");
do {
modified = 0;
83,7 → 84,12
if (cuc_debug >= 3) print_cuc_bb (func, "AFTER_CSE");
modified = 1;
}
if (cuc_debug) cuc_check (func);
if (first) {
insert_conditional_facts (func);
if (cuc_debug >= 3) print_cuc_bb (func, "AFTER_COND_FACT");
if (cuc_debug) cuc_check (func);
first = 0;
}
if (optimize_bb (func)) {
if (cuc_debug >= 5) print_cuc_bb (func, "AFTER_OPT_BB");
modified = 1;
107,6 → 113,8
}
} while (modified);
set_io (func);
detect_max_values (func);
if (cuc_debug >= 5) print_cuc_bb (func, "AFTER_MAX_VALUES");
}
 
/* Pre/unrolls basic block and optimizes it */
192,11 → 200,6
log ("Detecting dependencies\n");
if (cuc_debug >= 2) print_cuc_bb (func, "AFTER_REG_DEP");
cuc_optimize (func);
if (cuc_debug) cuc_check (func);
insert_conditional_facts (func);
if (cuc_debug >= 3) print_cuc_bb (func, "AFTER_COND_FACT");
if (cuc_debug) cuc_check (func);
cuc_optimize (func);
#if 0
csm (func);
/trunk/or1ksim/cuc/Makefile
107,7 → 107,7
noinst_LIBRARIES = libcuc.a
 
libcuc_a_SOURCES = cuc.c cuc.h load.c bb.c memory.c \
verilog.c timings.c insn.c insn.h
verilog.c timings.c insn.c insn.h adv.c
 
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_HEADER = ../config.h
121,7 → 121,7
LIBS =
libcuc_a_LIBADD =
libcuc_a_OBJECTS = cuc.o load.o bb.o memory.o verilog.o timings.o \
insn.o
insn.o adv.o
COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
CCLD = $(CC)
LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@
132,8 → 132,8
 
TAR = gtar
GZIP_ENV = --best
DEP_FILES = .deps/bb.P .deps/cuc.P .deps/insn.P .deps/load.P \
.deps/memory.P .deps/timings.P .deps/verilog.P
DEP_FILES = .deps/adv.P .deps/bb.P .deps/cuc.P .deps/insn.P \
.deps/load.P .deps/memory.P .deps/timings.P .deps/verilog.P
SOURCES = $(libcuc_a_SOURCES)
OBJECTS = $(libcuc_a_OBJECTS)
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.