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 932 to Rev 933
    Reverse comparison

Rev 932 → Rev 933

/trunk/or1ksim/cuc/cuc.h
206,6 → 206,9
extern int reloc[MAX_INSNS];
extern FILE *flog;
 
/* returns log2(x) */
int log2 (unsigned long x);
 
/* Loads from file into global array insn */
int cuc_load (char *in_fn);
 
289,4 → 292,6
/* Calculate timings */
void analyse_timings (cuc_func *func, cuc_timings *timings);
 
/* Calculates facts, that are determined by conditionals */
void insert_conditional_facts (cuc_func *func);
#endif /* __DATAF_H__ */
/trunk/or1ksim/cuc/bb.c
462,7 → 462,7
 
#if 1
/* LRBB at start of succ BB is not valid anymore */
if (insn[n1].index == II_LRBB) {
if (n1 > 0 && insn[n1].index == II_LRBB) {
if (type == 1) {
/* We have two possibilities, how this could have happened:
1. we just moved second predecessor of succ to pred,
538,7 → 538,7
if (cuc_debug) cuc_check (f);
if (f->bb[succ].type & BB_END) {
f->bb[pred].type |= BB_END;
if (insn[ninsn - 1].type & IT_BRANCH && insn[ninsn - 1].op[0] == succ) {
if (ninsn > 0 && insn[ninsn - 1].type & IT_BRANCH && insn[ninsn - 1].op[0] == succ) {
assert (insn[ninsn - 1].opt[0] & OPT_BB);
insn[ninsn - 1].op[0] = BBID_END;
}
593,7 → 593,7
f->bb[succ].type = BB_DEAD;
//printf (" %x %x %x %x %x\n", f->bb[pred].next[0], f->bb[pred].next[1], f->bb[succ].next[0], f->bb[succ].next[1], insn[ninsn - 1].type);
/* remove branch instruction, if there is only one successor */
if (f->bb[pred].next[1] < 0 && insn[ninsn - 1].type & IT_BRANCH) {
if (f->bb[pred].next[1] < 0 && ninsn > 0 && insn[ninsn - 1].type & IT_BRANCH) {
assert (f->bb[pred].next[0] != pred); /* end BB, loop should not be possible */
change_insn_type (&insn[ninsn - 1], II_NOP);
}
1268,7 → 1268,7
}
/* {z = x || y;} is same as {z = x ? x : y;} */
ii->op[3] = ii->op[1]; ii->opt[3] = ii->opt[1];
ii->type |= IT_COND;
ii->type = IT_COND;
 
/* Only one should be in loop, so we remove any INLOOP flags from duplicates */
n->bb[b1].type &= ~(BB_END | BB_INLOOP);
1412,7 → 1412,7
}
/* {z = x || y;} is same as {z = x ? x : y;} */
ii->op[3] = ii->op[1]; ii->opt[3] = ii->opt[1];
ii->type |= IT_COND;
ii->type = IT_COND;
 
/* Only one should be in loop, so we remove any INLOOP flags from duplicates */
n->bb[b1].type &= ~(BB_END | BB_INLOOP);
1502,3 → 1502,105
free (counts);
return n;
}
 
/* Calculates facts, that are determined by conditionals */
void insert_conditional_facts (cuc_func *f)
{
int b, i, j;
cuc_insn n[2];
for (b = 0; b < f->num_bb; b++) {
cuc_insn *ii = &f->bb[b].insn[f->bb[b].ninsn - 1];
if (ii->type & IT_BRANCH
&& ii->opt[1] & OPT_REF && f->INSN(ii->op[1]).opt[2] & OPT_CONST) {
int ok = 1;
unsigned long c = f->INSN(ii->op[1]).op[2];
change_insn_type (&n[0], II_NOP);
change_insn_type (&n[1], II_NOP);
/* 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].type = 0;
n[0].dep = NULL;
n[0].op[0] = -1; 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].type = 0;
n[1].dep = NULL;
n[1].op[0] = -1; 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].type = 0;
n[0].dep = NULL;
n[0].op[0] = -1; n[0].opt[0] = OPT_REGISTER | OPT_DEST;
n[0].op[1] = 0; n[0].opt[1] = OPT_CONST;
n[0].op[2] = (1 << (log2 (c) + 1)) - 1; n[0].opt[2] = OPT_CONST;
break;
case II_SFGT:
change_insn_type (&n[1], II_ADD);
n[1].type = 0;
n[1].dep = NULL;
n[1].op[0] = -1; n[1].opt[0] = OPT_REGISTER | OPT_DEST;
n[1].op[1] = 0; n[1].opt[1] = OPT_CONST;
n[1].op[2] = (1 << (log2 (c + 1) + 1)) - 1; n[1].opt[2] = OPT_CONST;
break;
case II_SFLE:
change_insn_type (&n[0], II_AND);
n[0].type = 0;
n[0].dep = NULL;
n[0].op[0] = -1; n[0].opt[0] = OPT_REGISTER | OPT_DEST;
n[0].op[1] = 0; n[0].opt[1] = OPT_CONST;
n[0].op[2] = (1 << (log2 (c + 1) + 1)) - 1; n[0].opt[2] = OPT_CONST;
break;
case II_SFGE:
change_insn_type (&n[1], II_ADD);
n[1].type = 0;
n[1].dep = NULL;
n[1].op[0] = -1; n[1].opt[0] = OPT_REGISTER | OPT_DEST;
n[1].op[1] = 0; n[1].opt[1] = OPT_CONST;
n[1].op[2] = (1 << (log2 (c) + 1)) - 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;
}
}
}
}
}
 
/trunk/or1ksim/cuc/verilog.c
28,16 → 28,6
/* Shortcut */
#define GEN(x...) fprintf (fo, x)
 
/* returns log2(x) */
int log2 (unsigned long x)
{
int c = 0;
assert (x >= 0);
if (!x) return 0; /* not by the book, but practical */
while (x != 1) x >>= 1, c++;
return c;
}
 
/* Find index of load/store/call */
int find_lsc_index (cuc_func *f, int ref)
{
/trunk/or1ksim/cuc/cuc.c
42,6 → 42,16
0, 1, 0, 1, 0, 1, 0, 1,
1, 1};
 
/* returns log2(x) */
int log2 (unsigned long x)
{
int c = 0;
assert (x >= 0);
if (!x) return 0; /* not by the book, but practical */
while (x != 1) x >>= 1, c++;
return c;
}
 
/* Does all known instruction optimizations */
void cuc_optimize (cuc_func *func)
{
48,6 → 58,7
int modified = 0;
log ("Optimizing.\n");
insert_conditional_facts (func);
if (cuc_debug >= 3) print_cuc_bb (func, "AFTER_COND_FACT");
do {
modified = 0;
if (optimize_cmovs (func)) {

powered by: WebSVN 2.1.0

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