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

Subversion Repositories or1k

[/] [or1k/] [tags/] [nog_patch_61/] [or1ksim/] [cuc/] [load.c] - Diff between revs 997 and 1043

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

Rev 997 Rev 1043
Line 103... Line 103...
  for (i = 0; i < num_insn; i++) {
  for (i = 0; i < num_insn; i++) {
    if (in_delay) insn[i].type |= IT_INDELAY;
    if (in_delay) insn[i].type |= IT_INDELAY;
    in_delay = 0;
    in_delay = 0;
    if (insn[i].type & IT_BRANCH) in_delay = 1;
    if (insn[i].type & IT_BRANCH) in_delay = 1;
    if (insn[i].type & IT_INDELAY) {
    if (insn[i].type & IT_INDELAY) {
 
      cuc_insn *ii;
 
      cuc_insn *bi;
 
      assert (i >= 2);
 
      ii = &insn[i - 2];
 
      bi = &insn[i - 1];
      /* delay slot should not be a branch target! */
      /* delay slot should not be a branch target! */
      assert ((insn[i].type & IT_BBSTART) == 0);
      assert ((insn[i].type & IT_BBSTART) == 0);
      assert ((insn[i - 1].type & IT_INDELAY) == 0);
      assert ((bi->type & IT_INDELAY) == 0);
      insn[i].type &= ~IT_INDELAY; /* no more in delay slot */
      insn[i].type &= ~IT_INDELAY; /* no more in delay slot */
 
 
 
      /* Get the value we need before the actual jump */
 
      if (bi->opt[1] & OPT_REGISTER && bi->op[1] >= 0) {
 
        int r = bi->op[1];
 
        assert (ii->index == II_NOP);
 
        change_insn_type (ii, II_ADD);
 
        ii->type = IT_COND;
 
        ii->dep = NULL;
 
        ii->op[0] = r; ii->opt[0] = OPT_REGISTER | OPT_DEST;
 
        ii->op[1] = r; ii->opt[1] = OPT_REGISTER;
 
        ii->op[2] = 0; ii->opt[2] = OPT_CONST;
 
        ii->opt[3] = OPT_NONE;
 
        bi->op[1] = i - 2; bi->opt[1] = OPT_REF;
 
      }
      xchg_insn (i, i - 1);
      xchg_insn (i, i - 1);
    }
    }
  }
  }
  assert (in_delay == 0);
  assert (in_delay == 0);
}
}
Line 204... Line 223...
    }
    }
  }
  }
  return name;
  return name;
}
}
 
 
 
/* inserts nop before branch */
 
void expand_branch ()
 
{
 
  int i, j, num_bra = 0, d;
 
  for (i = 0; i < num_insn; i++) if (insn[i].type & IT_BRANCH) num_bra++;
 
 
 
  d = num_insn + num_bra;
 
  assert (d < MAX_INSNS);
 
 
 
  /* Split memory commands */
 
  for (i = num_insn - 1; i >= 0; i--) if (insn[i].type & IT_BRANCH) {
 
    insn[--d] = insn[i];
 
    insn[--d] = insn[i];
 
    reloc[i] = d;
 
    change_insn_type (&insn[d], II_NOP);
 
  } else {
 
    insn[--d] = insn[i];
 
    reloc[i] = d;
 
  }
 
  num_insn += num_bra;
 
  for (i = 0; i < num_insn; i++)
 
    for (j = 0; j < MAX_OPERANDS; j++)
 
      if (insn[i].opt[j] & OPT_REF || insn[i].opt[j] & OPT_JUMP)
 
        insn[i].op[j] = reloc[insn[i].op[j]];
 
}
 
 
/* expands immediate memory instructions to two */
/* expands immediate memory instructions to two */
void expand_memory ()
void expand_memory ()
{
{
  int i, j, num_mem = 0, d;
  int i, j, num_mem = 0, d;
  for (i = 0; i < num_insn; i++) if (insn[i].type & IT_MEMORY) num_mem++;
  for (i = 0; i < num_insn; i++) if (insn[i].type & IT_MEMORY) num_mem++;
Line 444... Line 489...
 
 
  log ("Number of instructions loaded = %i\n", num_insn);
  log ("Number of instructions loaded = %i\n", num_insn);
  if (cuc_debug >= 3) print_cuc_insns ("INITIAL", 1);
  if (cuc_debug >= 3) print_cuc_insns ("INITIAL", 1);
 
 
  log ("Converting.\n");
  log ("Converting.\n");
 
  expand_branch ();
 
  if (cuc_debug >= 6) print_cuc_insns ("AFTER_EXP_BRANCH", 0);
 
 
  remove_dslots ();
  remove_dslots ();
  if (cuc_debug >= 6) print_cuc_insns ("NO_DELAY_SLOTS", 0);
  if (cuc_debug >= 6) print_cuc_insns ("NO_DELAY_SLOTS", 0);
 
 
  if (config.cuc.calling_convention) {
  if (config.cuc.calling_convention) {
    detect_locals ();
    detect_locals ();
Line 459... Line 507...
  expand_signed ();
  expand_signed ();
  if (cuc_debug >= 3) print_cuc_insns ("AFTER_EXP_SIG", 0);
  if (cuc_debug >= 3) print_cuc_insns ("AFTER_EXP_SIG", 0);
 
 
  expand_calls ();
  expand_calls ();
  if (cuc_debug >= 3) print_cuc_insns ("AFTER_EXP_CALLS", 0);
  if (cuc_debug >= 3) print_cuc_insns ("AFTER_EXP_CALLS", 0);
 
 
  return 0;
  return 0;
}
}
 
 
 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.