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

Subversion Repositories or1k

[/] [or1k/] [tags/] [nog_patch_34/] [or1ksim/] [cuc/] [memory.c] - Diff between revs 904 and 907

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

Rev 904 Rev 907
Line 159... Line 159...
#endif
#endif
 
 
  /* Assign memory types */
  /* Assign memory types */
  for (i = 0; i < f->nmsched; i++) {
  for (i = 0; i < f->nmsched; i++) {
    cuc_insn *a = &f->INSN(f->msched[i]);
    cuc_insn *a = &f->INSN(f->msched[i]);
    f->mtype[i] = !II_IS_LOAD(a->index) ? MT_WRITE : 0;
    f->mtype[i] = !II_IS_LOAD(a->index) ? MT_STORE : MT_LOAD;
    f->mtype[i] |= II_MEM_WIDTH (a->index);
    f->mtype[i] |= II_MEM_WIDTH (a->index);
    if (a->type & IT_SIGNED) f->mtype[i] |= MT_SIGNED;
    if (a->type & IT_SIGNED) f->mtype[i] |= MT_SIGNED;
  }
  }
 
 
  /* Check if they address the same location, so we can join them */
  /* Check if they address the same location, so we can join them */
  if (otype == MO_WEAK || otype == MO_NONE) {
  if (otype == MO_WEAK || otype == MO_NONE) {
    for (i = 1, j = 1; i < f->nmsched; i++)
    for (i = 1, j = 1; i < f->nmsched; i++)
      /* Exclude memory stores and different memory types */
      /* Exclude memory stores and different memory types */
      if (f->mtype[i - 1] == f->mtype[i] && !(f->mtype[i] & MT_WRITE)) {
      if (f->mtype[i - 1] == f->mtype[i] && f->mtype[i] & MT_LOAD) {
        cuc_insn *a = &f->INSN(f->msched[i - 1]);
        cuc_insn *a = &f->INSN(f->msched[i - 1]);
        cuc_insn *b = &f->INSN(f->msched[i]);
        cuc_insn *b = &f->INSN(f->msched[i]);
        if ((a->opt[1] & OPT_REF) && f->INSN(a->op[1]).index == II_ADD
        if ((a->opt[1] & OPT_REF) && f->INSN(a->op[1]).index == II_ADD
          &&(b->opt[1] & OPT_REF) && f->INSN(b->op[1]).index == II_ADD) {
          &&(b->opt[1] & OPT_REF) && f->INSN(b->op[1]).index == II_ADD) {
          a = &f->INSN(a->op[1]);
          a = &f->INSN(a->op[1]);
Line 252... Line 252...
      dispose_list (&insn[i].dep);
      dispose_list (&insn[i].dep);
  }
  }
 
 
  /* Reduce number of dependecies, keeping just direct dependencies, based on memory schedule */
  /* Reduce number of dependecies, keeping just direct dependencies, based on memory schedule */
  {
  {
    int lastl[2] = {-1, -1}, lasts[2] = {-1, -1};
    int lastl[3] = {-1, -1, -1};
    int last_load = -1, last_store = -1;
    int lasts[3] = {-1, -1, -1};
 
    int lastc[3] = {-1, -1, -1};
 
    int last_load = -1, last_store = -1, last_call = -1;
    for (i = 0; i < f->nmsched; i++) {
    for (i = 0; i < f->nmsched; i++) {
      int t = (f->mtype[i] & MT_WRITE) ? 1 : 0;
      int t = f->mtype[i] & MT_LOAD ? 0 : f->mtype[i] & MT_STORE ? 1 : 2;
      int maxl = lastl[t];
      int maxl = lastl[t];
      int maxs = lasts[t];
      int maxs = lasts[t];
 
      int maxc = lastc[t];
      dep_list *tmp = f->INSN(f->msched[i]).dep;
      dep_list *tmp = f->INSN(f->msched[i]).dep;
      while (tmp) {
      while (tmp) {
        if (f->INSN(tmp->ref).type & IT_MEMORY && REF_BB(tmp->ref) == REF_BB(f->msched[i])) {
        if (f->INSN(tmp->ref).type & IT_MEMORY && REF_BB(tmp->ref) == REF_BB(f->msched[i])) {
          /* Search for the reference */
          /* Search for the reference */
          for (j = 0; j < f->nmsched; j++) if (f->msched[j] == tmp->ref) break;
          for (j = 0; j < f->nmsched; j++) if (f->msched[j] == tmp->ref) break;
          assert (j < f->nmsched);
          assert (j < f->nmsched);
          if (f->mtype[j] & MT_WRITE) {
          if (f->mtype[j] & MT_STORE) {
            if (maxs < j) maxs = j;
            if (maxs < j) maxs = j;
          } else {
          } else if (f->mtype[j] & MT_LOAD) {
            if (maxl < j) maxl = j;
            if (maxl < j) maxl = j;
 
          } else if (f->mtype[j] & MT_CALL) {
 
            if (maxc < j) maxc = j;
          }
          }
        }
        }
        tmp = tmp->next;
        tmp = tmp->next;
      }
      }
      dispose_list (&f->INSN(f->msched[i]).dep);
      dispose_list (&f->INSN(f->msched[i]).dep);
      if (f->mtype[i] & MT_WRITE) {
      if (f->mtype[i] & MT_STORE) {
        maxs = last_store;
        maxs = last_store;
        last_store = i;
        last_store = i;
      } else {
      } else if (f->mtype[i] & MT_LOAD) {
        maxl = last_load;
        maxl = last_load;
        last_load = i;
        last_load = i;
 
      } else if (f->mtype[i] & MT_CALL) {
 
        maxc = last_call;
 
        last_call = i;
      }
      }
 
 
      if (maxl > lastl[t]) {
      if (maxl > lastl[t]) {
        add_dep (&f->INSN(f->msched[i]).dep, f->msched[maxl]);
        add_dep (&f->INSN(f->msched[i]).dep, f->msched[maxl]);
        lastl[t] = maxl;
        lastl[t] = maxl;
      }
      }
      if (maxs > lasts[t]) {
      if (maxs > lasts[t]) {
        add_dep (&f->INSN(f->msched[i]).dep, f->msched[maxs]);
        add_dep (&f->INSN(f->msched[i]).dep, f->msched[maxs]);
        lasts[t] = maxs;
        lasts[t] = maxs;
      }
      }
 
      if (maxc > lastc[t]) {
 
        add_dep (&f->INSN(f->msched[i]).dep, f->msched[maxc]);
 
        lastc[t] = maxc;
 
      }
      //printf ("%i(%i)> ml %i(%i) ms %i(%i) lastl %i %i lasts %i %i last_load %i last_store %i\n", i, f->msched[i], maxl, f->msched[maxl], maxs, f->msched[maxs], lastl[0], lastl[1], lasts[0], lasts[1], last_load, last_store);
      //printf ("%i(%i)> ml %i(%i) ms %i(%i) lastl %i %i lasts %i %i last_load %i last_store %i\n", i, f->msched[i], maxl, f->msched[maxl], maxs, f->msched[maxs], lastl[0], lastl[1], lasts[0], lasts[1], last_load, last_store);
 
 
      /* What we have to wait to finish this BB? */
      /* What we have to wait to finish this BB? */
      if (i + 1 >= f->nmsched || REF_BB(f->msched[i + 1]) != REF_BB(f->msched[i])) {
      if (i + 1 >= f->nmsched || REF_BB(f->msched[i + 1]) != REF_BB(f->msched[i])) {
        if (last_load > lastl[t]) {
        if (last_load > lastl[t]) {
Line 301... Line 313...
        }
        }
        if (last_store > lasts[t]) {
        if (last_store > lasts[t]) {
          add_dep (&f->bb[REF_BB(f->msched[i])].mdep, f->msched[last_store]);
          add_dep (&f->bb[REF_BB(f->msched[i])].mdep, f->msched[last_store]);
          lasts[t] = last_store;
          lasts[t] = last_store;
        }
        }
 
        if (last_call > lastc[t]) {
 
          add_dep (&f->bb[REF_BB(f->msched[i])].mdep, f->msched[last_call]);
 
          lastc[t] = last_call;
 
        }
      }
      }
    }
    }
  }
  }
}
}
 
 
 No newline at end of file
 No newline at end of file

powered by: WebSVN 2.1.0

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