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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [or1ksim/] [cuc/] [bb.c] - Diff between revs 924 and 925

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 924 Rev 925
Line 25... Line 25...
#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"
 
 
 
/* prints out bb string */
 
void print_bb_num (int num)
 
{
 
  if (num < 0) printf ("*");
 
  else if (num == BBID_END) printf ("END");
 
  else printf ("%2x", num);
 
}
 
 
/* Print out basic blocks */
/* Print out basic blocks */
void print_cuc_bb (cuc_func *f, char *s)
void print_cuc_bb (cuc_func *f, char *s)
{
{
  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 %02x tmp %i ", f->bb[i].type, f->bb[i].tmp);
    if (f->bb[i].next[0] >= 0) printf ("next %2x ", f->bb[i].next[0]);
    printf ("next "); print_bb_num (f->bb[i].next[0]);
    else printf ("next * ");
    printf (" "); print_bb_num (f->bb[i].next[1]);
    if (f->bb[i].next[1] >= 0) printf ("%2x ", f->bb[i].next[1]);
    printf (" prev "); print_bb_num (f->bb[i].prev[0]);
    else printf ("* ");
    printf (" "); print_bb_num (f->bb[i].prev[1]);
    if (f->bb[i].prev[0] >= 0) printf ("prev %2x ", f->bb[i].prev[0]);
    printf ("\n");
    else printf ("prev * ");
 
    if (f->bb[i].prev[1] >= 0) printf ("%2x\n", f->bb[i].prev[1]);
 
    else printf ("*\n");
 
 
 
    if (f->bb[i].insn) print_insns (f->bb[i].insn, f->bb[i].ninsn, 0);
    if (f->bb[i].insn) print_insns (f->bb[i].insn, f->bb[i].ninsn, 0);
  }
  }
  printf ("\n");
  printf ("\n");
  fflush (stdout);
  fflush (stdout);
Line 226... Line 231...
    f->bb[--end_bb] = f->bb[i];
    f->bb[--end_bb] = f->bb[i];
    reloc[i] = end_bb;
    reloc[i] = end_bb;
    while (j-- > 2) {
    while (j-- > 2) {
      f->bb[--end_bb].first = f->bb[i].first;
      f->bb[--end_bb].first = f->bb[i].first;
      f->bb[end_bb].last = -1;
      f->bb[end_bb].last = -1;
 
      f->bb[end_bb].type &= ~BB_END;
      f->bb[end_bb].next[0] = -1;
      f->bb[end_bb].next[0] = -1;
      f->bb[end_bb].next[1] = -1;
      f->bb[end_bb].next[1] = -1;
      f->bb[end_bb].tmp = 0;
      f->bb[end_bb].tmp = 0;
      f->bb[end_bb].cnt = f->bb[i].cnt;
      f->bb[end_bb].cnt = f->bb[i].cnt;
      f->bb[end_bb].ntim = 0;
      f->bb[end_bb].ntim = 0;
Line 299... Line 305...
        assert (f->bb[t].prev[1] < 0);
        assert (f->bb[t].prev[1] < 0);
        f->bb[t].prev[1] = i;
        f->bb[t].prev[1] = i;
      }
      }
    }
    }
  }
  }
 
  /* Add END marker */
 
  for (i = 0; i < f->num_bb; i++)
 
    if (f->bb[i].type & BB_END) {
 
      assert (f->bb[i].next[0] < 0);
 
      f->bb[i].next[0] = BBID_END;
 
    }
  if (cuc_debug >= 3) print_cuc_bb (f, "AFTER_PREV");
  if (cuc_debug >= 3) print_cuc_bb (f, "AFTER_PREV");
}
}
 
 
/* We do a quick check if there are some anomalies with references */
/* We do a quick check if there are some anomalies with references */
void cuc_check (cuc_func *f)
void cuc_check (cuc_func *f)
Line 433... Line 445...
  }
  }
 
 
#if 1
#if 1
  /* LRBB at start of succ BB is not valid, it should be set when */
  /* LRBB at start of succ BB is not valid, it should be set when */
  if (insn[n1].index == II_LRBB) {
  if (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,
 
            pred now having two predecessors => everything is ok
 
         2. we just moved second predecessor of succ to pred,
 
            now, having just one predecessor => LRBB is not needed anymore */
 
      if (f->bb[pred].prev[1] < 0) { /* handle second option */
 
        change_insn_type (&insn[n1], II_ADD);
 
        insn[n1].op[1] = 1; insn[n1].opt[1] = OPT_CONST;
 
        insn[n1].op[2] = 0; insn[n1].opt[2] = OPT_CONST;
 
        insn[n1].opt[3] = OPT_NONE;
 
      }
 
    } else {
    assert (0); /* not tested yet */
    assert (0); /* not tested yet */
    change_insn_type (&insn[n1], II_NOP);
    change_insn_type (&insn[n1], II_NOP);
    for (i = n1; i < ninsn; i++)
    for (i = n1; i < ninsn; i++)
      if (insn[i].index == II_CMOV && insn[i].op[3] == REF (pred, n1)) {
      if (insn[i].index == II_CMOV && insn[i].op[3] == REF (pred, n1)) {
        assert (insn[i].opt[3] == OPT_REF);
        assert (insn[i].opt[3] == OPT_REF);
Line 452... Line 477...
          insn[i].opt[1] = insn[i].opt[2];
          insn[i].opt[1] = insn[i].opt[2];
          insn[i].opt[2] = t;
          insn[i].opt[2] = t;
        }
        }
      }
      }
  }
  }
 
  }
#endif
#endif
 
 
  for (i = 0; i < ninsn; i++) reloc[i] = -1;
  for (i = 0; i < ninsn; i++) reloc[i] = -1;
 
 
  /* Add conditional instructions if required */
  /* Add conditional instructions if required */
Line 494... Line 520...
      sprintf (ii->disasm, "cmov (join BB)");
      sprintf (ii->disasm, "cmov (join BB)");
    }
    }
  }
  }
 
 
  if (cuc_debug) cuc_check (f);
  if (cuc_debug) cuc_check (f);
  f->bb[pred].type |= f->bb[succ].type;
  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) {
 
      assert (insn[ninsn - 1].opt[0] & OPT_BB);
 
      insn[ninsn - 1].op[0] = BBID_END;
 
    }
 
  }
  i = 0;
  i = 0;
  assert (f->bb[pred].next[0] >= 0);
  assert (f->bb[pred].next[0] >= 0 && f->bb[pred].next[0] != BBID_END);
  switch (type) {
  switch (type) {
  case 0:
  case 0:
    if (f->bb[pred].next[0] == succ) f->bb[pred].next[0] = f->bb[succ].next[0];
    if (f->bb[pred].next[0] == succ) f->bb[pred].next[0] = f->bb[succ].next[0];
    if (f->bb[pred].next[1] == succ) f->bb[pred].next[1] = f->bb[succ].next[0];
    if (f->bb[pred].next[1] == succ) f->bb[pred].next[1] = f->bb[succ].next[0];
    assert (f->bb[succ].next[1] < 0);
    assert (f->bb[succ].next[1] < 0);
Line 517... Line 549...
  if (f->bb[pred].next[0] < 0) f->bb[pred].next[0] = f->bb[pred].next[1];
  if (f->bb[pred].next[0] < 0) f->bb[pred].next[0] = f->bb[pred].next[1];
  if (f->bb[pred].next[0] == f->bb[pred].next[1]) f->bb[pred].next[1] = -1;
  if (f->bb[pred].next[0] == f->bb[pred].next[1]) f->bb[pred].next[1] = -1;
  f->bb[succ].type = BB_DEAD;
  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);
  //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 */
  /* 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 && insn[ninsn - 1].type & IT_BRANCH) {
    && f->bb[pred].next[0] != pred) /* not when end BB, loop */
    assert (f->bb[pred].next[0] != pred); /* end BB, loop should not be possible */
    change_insn_type (&insn[ninsn - 1], II_NOP);
    change_insn_type (&insn[ninsn - 1], II_NOP);
 
  }
 
 
  /* Set max count */
  /* Set max count */
  if (f->bb[pred].cnt < f->bb[succ].cnt) f->bb[pred].cnt = f->bb[succ].cnt;
  if (f->bb[pred].cnt < f->bb[succ].cnt) f->bb[pred].cnt = f->bb[succ].cnt;
  f->bb[pred].ninsn = ninsn;
  f->bb[pred].ninsn = ninsn;
  f->bb[succ].ninsn = 0;
  f->bb[succ].ninsn = 0;
Line 567... Line 600...
  for (i = 0; i < f->num_bb; i++) if (!(f->bb[i].type & BB_DEAD)) {
  for (i = 0; i < f->num_bb; i++) if (!(f->bb[i].type & BB_DEAD)) {
    if (f->bb[i].prev[0] >= 0 && f->bb[i].prev[1] < 0) { /* exactly one predecessor */
    if (f->bb[i].prev[0] >= 0 && f->bb[i].prev[1] < 0) { /* exactly one predecessor */
      for (j = 0; j < f->bb[i].ninsn; j++)
      for (j = 0; j < f->bb[i].ninsn; j++)
        if (f->bb[i].insn[j].index == II_LRBB) {
        if (f->bb[i].insn[j].index == II_LRBB) {
          cuc_insn *t;
          cuc_insn *t;
          cucdebug (4, "-lrbb %i.%i\n", i, j);
          cucdebug (4, "-lrbb %x.%x\n", i, j);
 
 
          /* Change to add LRBB, 0, 0 */
          /* Change to add LRBB, 0, 0 */
          change_insn_type (&f->bb[i].insn[j], II_ADD);
          change_insn_type (&f->bb[i].insn[j], II_ADD);
          f->bb[i].insn[j].type &= ~IT_VOLATILE;
          f->bb[i].insn[j].type &= ~IT_VOLATILE;
          t = &f->bb[f->bb[i].prev[0]].insn[f->bb[f->bb[i].prev[0]].ninsn - 1];
          t = &f->bb[f->bb[i].prev[0]].insn[f->bb[f->bb[i].prev[0]].ninsn - 1];
          f->bb[i].insn[j].opt[1] = f->bb[i].insn[j].opt[2] = OPT_CONST;
          f->bb[i].insn[j].opt[1] = f->bb[i].insn[j].opt[2] = OPT_CONST;
          f->bb[i].insn[j].op[1] = f->bb[i].insn[j].op[2] = 0; /* always use left block */
          f->bb[i].insn[j].op[1] = f->bb[i].insn[j].op[2] = 0; /* always use left block */
          f->bb[i].insn[j].opt[3] = OPT_NONE;
          f->bb[i].insn[j].opt[3] = OPT_NONE;
 
 
          /* If the predecessor still has a conditional jump instruction, we must be careful.
          /* If the predecessor still has a conditional jump instruction, we must be careful.
             This could only have occured when we found out that next[0] == next[1] and have
             If next[0] == next[1] join them. Now we will link lrbb and correct the situation */
             joined them. Now we will link lrbb and correct the situation */
 
          if (t->type & IT_BRANCH) { /* We must set a reference to branch result */
          if (t->type & IT_BRANCH) { /* We must set a reference to branch result */
            f->bb[i].insn[j].opt[1] = t->opt[1];
            f->bb[i].insn[j].opt[1] = t->opt[1];
            f->bb[i].insn[j].op[1] = t->op[1];
            f->bb[i].insn[j].op[1] = t->op[1];
            change_insn_type (t, II_NOP);
            /* sometimes branch is not needed anymore */
 
            if (f->bb[f->bb[i].prev[0]].next[1] < 0) change_insn_type (t, II_NOP);
          }
          }
        }
        }
    }
    }
  }
  }
 
 
Line 605... Line 638...
    }
    }
 
 
  /* Type 1 joining
  /* Type 1 joining
     1. link between pred & succ
     1. link between pred & succ
     2. no other pred's successors
     2. no other pred's successors
     3. no other succ's predecessors */
     3. no other succ's predecessors, except if pred has max one */
  for (i = 0; i < f->num_bb; i++) if (!(f->bb[i].type & BB_DEAD))
  for (i = 0; i < f->num_bb; i++) if (!(f->bb[i].type & BB_DEAD))
    if (f->bb[i].prev[0] >= 0 && f->bb[i].prev[1] < 0 /* one predecessor */
    /* one successor and max sum of 3 predecessors */
     && f->bb[f->bb[i].prev[0]].next[0] >= 0 && f->bb[f->bb[i].prev[0]].next[1] < 0) { /* one successor */
    if (f->bb[f->bb[i].prev[0]].next[0] >= 0 && f->bb[f->bb[i].prev[0]].next[1] < 0
 
     && (f->bb[f->bb[i].prev[0]].prev[1] < 0 || f->bb[i].prev[1] < 0)) {
 
      /* First we will move all predecessors from succ to pred, and then we will do
 
         real type 1 joining */
 
      if (f->bb[i].prev[1] >= 0) {
 
        /* joining is surely not worth another extra memory access */
 
        if (f->bb[f->bb[i].prev[0]].nmemory) continue;
 
        if (f->bb[f->bb[i].prev[0]].prev[0] >= 0) {
 
           assert (f->bb[f->bb[i].prev[0]].prev[1] < 0);
 
           f->bb[f->bb[i].prev[0]].prev[1] = f->bb[i].prev[1];
 
        } else f->bb[f->bb[i].prev[0]].prev[0] = f->bb[i].prev[1];
 
        if (f->bb[f->bb[i].prev[1]].next[0] == i)
 
          f->bb[f->bb[i].prev[1]].next[0] = f->bb[i].prev[0];
 
        else if (f->bb[f->bb[i].prev[1]].next[1] == i)
 
          f->bb[f->bb[i].prev[1]].next[1] = f->bb[i].prev[0];
 
        else assert (0);
 
        f->bb[i].prev[1] = -1;
 
      }
 
      assert (f->bb[i].prev[0] >= 0 && f->bb[i].prev[1] < 0); /* one predecessor */
      join_bb (f, f->bb[i].prev[0], i, 1);
      join_bb (f, f->bb[i].prev[0], i, 1);
      goto remove_lrbb;
      goto remove_lrbb;
    }
    }
 
 
#if 1
#if 1
Line 661... Line 712...
  for (i = 0; i < f->num_init_bb; i++)
  for (i = 0; i < f->num_init_bb; i++)
    f->init_bb_reloc[i] = reloc[f->init_bb_reloc[i]];
    f->init_bb_reloc[i] = reloc[f->init_bb_reloc[i]];
 
 
  /* repair references */
  /* repair references */
  for (i = 0; i < f->num_bb; i++) if (!(f->bb[i].type & BB_DEAD)) {
  for (i = 0; i < f->num_bb; i++) if (!(f->bb[i].type & BB_DEAD)) {
 
          printf ("%x %x %x %x %x\n", i, f->bb[i].prev[0], f->bb[i].prev[1], f->bb[i].next[0], f->bb[i].next[1]);
 
          fflush (stdout);
    if (f->bb[i].prev[0] >= 0) assert ((f->bb[i].prev[0] = reloc[f->bb[i].prev[0]]) >= 0);
    if (f->bb[i].prev[0] >= 0) assert ((f->bb[i].prev[0] = reloc[f->bb[i].prev[0]]) >= 0);
    if (f->bb[i].prev[1] >= 0) assert ((f->bb[i].prev[1] = reloc[f->bb[i].prev[1]]) >= 0);
    if (f->bb[i].prev[1] >= 0) assert ((f->bb[i].prev[1] = reloc[f->bb[i].prev[1]]) >= 0);
    if (f->bb[i].next[0] >= 0) assert ((f->bb[i].next[0] = reloc[f->bb[i].next[0]]) >= 0);
    if (f->bb[i].next[0] >= 0 && f->bb[i].next[0] != BBID_END)
    if (f->bb[i].next[1] >= 0) assert ((f->bb[i].next[1] = reloc[f->bb[i].next[1]]) >= 0);
      assert ((f->bb[i].next[0] = reloc[f->bb[i].next[0]]) >= 0);
 
    if (f->bb[i].next[1] >= 0 && f->bb[i].next[1] != BBID_END)
 
      assert ((f->bb[i].next[1] = reloc[f->bb[i].next[1]]) >= 0);
    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)
          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);
          f->bb[i].insn[j].op[k] = REF (reloc[REF_BB(t)], REF_I (t));
          f->bb[i].insn[j].op[k] = REF (reloc[REF_BB(t)], REF_I (t));
        }
        }
  }
  }
Line 702... Line 758...
        assert (insn[i].op[j] > 0 && insn[i].op[j] < MAX_REGS); /* r0 should never be dest */
        assert (insn[i].op[j] > 0 && insn[i].op[j] < MAX_REGS); /* r0 should never be dest */
        f->bb[cur].last_used_reg[insn[i].op[j]] = REF (cur, i);
        f->bb[cur].last_used_reg[insn[i].op[j]] = REF (cur, i);
      }
      }
  }
  }
 
 
  if (f->bb[cur].next[0] >= 0) reg_dep_rec (f, f->bb[cur].next[0]);
  if (f->bb[cur].next[0] >= 0 && f->bb[cur].next[0] != BBID_END)
  if (f->bb[cur].next[1] >= 0) reg_dep_rec (f, f->bb[cur].next[1]);
    reg_dep_rec (f, f->bb[cur].next[0]);
 
  if (f->bb[cur].next[1] >= 0 && f->bb[cur].next[1] != BBID_END)
 
    reg_dep_rec (f, f->bb[cur].next[1]);
}
}
 
 
/* Detect register dependencies */
/* Detect register dependencies */
void reg_dep (cuc_func *f)
void reg_dep (cuc_func *f)
{
{
Line 909... Line 967...
      f->bb[n + j].prev[1] = -1;
      f->bb[n + j].prev[1] = -1;
    } else {
    } else {
      i = f->bb[b1].next[0];
      i = f->bb[b1].next[0];
      f->bb[n + j].prev[0] = j == 1 ? b : b1 - 1;
      f->bb[n + j].prev[0] = j == 1 ? b : b1 - 1;
      f->bb[n + j].prev[1] = -1;
      f->bb[n + j].prev[1] = -1;
      if (i >= 0) {
      if (i >= 0 && i != BBID_END) {
        if (f->bb[i].prev[0] == b) f->bb[i].prev[0] = b1;
        if (f->bb[i].prev[0] == b) f->bb[i].prev[0] = b1;
        if (f->bb[i].prev[1] == b) f->bb[i].prev[1] = b1;
        if (f->bb[i].prev[1] == b) f->bb[i].prev[1] = b1;
      }
      }
      i = f->bb[b1].next[1];
      i = f->bb[b1].next[1];
      if (i >= 0) {
      if (i >= 0 && i != BBID_END) {
        if (f->bb[i].prev[0] == b) f->bb[i].prev[0] = b1;
        if (f->bb[i].prev[0] == b) f->bb[i].prev[0] = b1;
        if (f->bb[i].prev[1] == b) f->bb[i].prev[1] = b1;
        if (f->bb[i].prev[1] == b) f->bb[i].prev[1] = b1;
      }
      }
    }
    }
  }
  }
Line 1151... Line 1209...
 
 
    /* Only one should be in loop, so we remove any INLOOP flags from duplicates */
    /* Only one should be in loop, so we remove any INLOOP flags from duplicates */
    n->bb[b1].type &= ~(BB_END | BB_INLOOP);
    n->bb[b1].type &= ~(BB_END | BB_INLOOP);
    n->bb[b1].prev[0] = prevart_b;
    n->bb[b1].prev[0] = prevart_b;
    n->bb[b1].prev[1] = b1 - 1;
    n->bb[b1].prev[1] = b1 - 1;
    n->bb[b1].next[0] = ob->next[0] == b ? ob->next[1] : ob->next[0];
    n->bb[b1].next[0] = -1;
    n->bb[b1].next[1] = -1;
    n->bb[b1].next[1] = -1;
 
 
    prevb = b1 - 1;
    prevb = b1 - 1;
    prevart_b = b1;
    prevart_b = b1;
  }
  }
  if (ob->type & BB_END) {
  if (ob->type & BB_END) {
    n->bb[prevart_b].type |= BB_END;
    n->bb[prevart_b].type |= BB_END;
    n->bb[b].type &= ~BB_END;
    n->bb[b].type &= ~BB_END;
  }
  }
 
 
 
  n->bb[prevart_b].next[0] = ob->next[0] == b ? ob->next[1] : ob->next[0];
  //print_cuc_bb (n, "unroll1");
  //print_cuc_bb (n, "unroll1");
  /* repair BB after loop, to point back to latest artificial BB */
  /* repair BB after loop, to point back to latest artificial BB */
  b1 = n->bb[prevart_b].next[0];
  b1 = n->bb[prevart_b].next[0];
  if (b1 >= 0) {
  if (b1 >= 0 && b1 != BBID_END) {
    if (n->bb[b1].prev[0] == b) n->bb[b1].prev[0] = prevart_b;
    if (n->bb[b1].prev[0] == b) n->bb[b1].prev[0] = prevart_b;
    else if (n->bb[b1].prev[1] == b) n->bb[b1].prev[1] = prevart_b;
    else if (n->bb[b1].prev[1] == b) n->bb[b1].prev[1] = prevart_b;
    else assert (0);
    else assert (0);
  }
  }
 
 
Line 1293... Line 1352...
 
 
    /* Only one should be in loop, so we remove any INLOOP flags from duplicates */
    /* Only one should be in loop, so we remove any INLOOP flags from duplicates */
    n->bb[b1].type &= ~(BB_END | BB_INLOOP);
    n->bb[b1].type &= ~(BB_END | BB_INLOOP);
    n->bb[b1].prev[0] = prevart_b;
    n->bb[b1].prev[0] = prevart_b;
    n->bb[b1].prev[1] = b1 - 1;
    n->bb[b1].prev[1] = b1 - 1;
    n->bb[b1].next[0] = ob->next[0] == b ? ob->next[1] : ob->next[0];
    n->bb[b1].next[0] = -1;
    n->bb[b1].next[1] = -1;
    n->bb[b1].next[1] = -1;
 
 
    prevb = b1 - 1;
    prevb = b1 - 1;
    prevart_b = b1;
    prevart_b = b1;
  }
  }
  if (ob->type & BB_END) {
  if (ob->type & BB_END) {
    n->bb[prevart_b].type |= BB_END;
    n->bb[prevart_b].type |= BB_END;
    n->bb[b].type &= ~BB_END;
    n->bb[b].type &= ~BB_END;
  }
  }
 
  n->bb[prevart_b].next[0] = ob->next[0] == b ? ob->next[1] : ob->next[0];
 
 
  //print_cuc_bb (n, "preroll1");
  //print_cuc_bb (n, "preroll1");
  /* repair BB after loop, to point back to latest artificial BB */
  /* repair BB after loop, to point back to latest artificial BB */
  b1 = n->bb[prevart_b].next[0];
  b1 = n->bb[prevart_b].next[0];
  if (b1 >= 0) {
  if (b1 >= 0 && b1 != BBID_END) {
    if (n->bb[b1].prev[0] == b) n->bb[b1].prev[0] = prevart_b;
    if (n->bb[b1].prev[0] == b) n->bb[b1].prev[0] = prevart_b;
    else if (n->bb[b1].prev[1] == b) n->bb[b1].prev[1] = prevart_b;
    else if (n->bb[b1].prev[1] == b) n->bb[b1].prev[1] = prevart_b;
    else assert (0);
    else assert (0);
  }
  }
 
 

powered by: WebSVN 2.1.0

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