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

Subversion Repositories or1k

[/] [or1k/] [tags/] [nog_patch_47/] [or1ksim/] [cuc/] [load.c] - Diff between revs 1061 and 1062

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

Rev 1061 Rev 1062
Line 67... Line 67...
/* Prints out instructions */
/* Prints out instructions */
void print_cuc_insns (char *s, int verbose)
void print_cuc_insns (char *s, int verbose)
{
{
  int i, j;
  int i, j;
  PRINTF ("****************** %s ******************\n", s);
  PRINTF ("****************** %s ******************\n", s);
  print_insns (insn, num_insn,verbose);
  print_insns (0, insn, num_insn,verbose);
  PRINTF ("\n\n");
  PRINTF ("\n\n");
}
}
 
 
void xchg_insn (int i, int j)
void xchg_insn (int i, int j)
{
{
Line 229... Line 229...
void expand_branch ()
void expand_branch ()
{
{
  int i, j, num_bra = 0, d;
  int i, j, num_bra = 0, d;
  for (i = 0; i < num_insn; i++) if (insn[i].type & IT_BRANCH) num_bra++;
  for (i = 0; i < num_insn; i++) if (insn[i].type & IT_BRANCH) num_bra++;
 
 
  d = num_insn + num_bra;
  d = num_insn + 2 * num_bra;
  assert (d < MAX_INSNS);
  assert (d < MAX_INSNS);
 
 
  /* Add nop before branch */
  /* Add nop before branch */
  for (i = num_insn - 1; i >= 0; i--) if (insn[i].type & IT_BRANCH) {
  for (i = num_insn - 1; i >= 0; i--) if (insn[i].type & IT_BRANCH) {
    insn[--d] = insn[i];
    insn[--d] = insn[i]; // for delay slot (later)
    insn[--d] = insn[i];
    if (insn[d].opt[1] & OPT_REGISTER) {
    reloc[i] = d;
      assert (insn[d].op[1] == FLAG_REG);
 
      insn[d].op[1] = i; insn[d].opt[1] = OPT_REF;
 
    }
 
    insn[--d] = insn[i]; // for branch
    change_insn_type (&insn[d], II_NOP);
    change_insn_type (&insn[d], II_NOP);
 
    insn[--d] = insn[i]; // save flag & negation of conditional, if required
 
    change_insn_type (&insn[d], II_CMOV);
 
    insn[d].op[0] = -1; insn[d].opt[0] = OPT_REGISTER | OPT_DEST;
 
    insn[d].op[1] = insn[d].type & IT_FLAG1 ? 0 : 1; insn[d].opt[1] = OPT_CONST;
 
    insn[d].op[2] = insn[d].type & IT_FLAG1 ? 1 : 0; insn[d].opt[2] = OPT_CONST;
 
    insn[d].op[3] = FLAG_REG; insn[d].opt[3] = OPT_REGISTER;
 
    insn[d].type = IT_COND;
 
    if (insn[d].type)
 
    reloc[i] = d;
  } else {
  } else {
    insn[--d] = insn[i];
    insn[--d] = insn[i];
    reloc[i] = d;
    reloc[i] = d;
  }
  }
  num_insn += num_bra;
  num_insn += 2 * num_bra;
  for (i = 0; i < num_insn; i++)
  for (i = 0; i < num_insn; i++)
    for (j = 0; j < MAX_OPERANDS; j++)
    for (j = 0; j < MAX_OPERANDS; j++)
      if (insn[i].opt[j] & OPT_REF || insn[i].opt[j] & OPT_JUMP)
      if (insn[i].opt[j] & OPT_REF || insn[i].opt[j] & OPT_JUMP)
        insn[i].op[j] = reloc[insn[i].op[j]];
        insn[i].op[j] = reloc[insn[i].op[j]];
}
}
Line 441... Line 453...
        change_insn_type (&insn[i], II_BF);
        change_insn_type (&insn[i], II_BF);
        insn[i].op[0] = i + insn[i].op[0]; insn[i].opt[0] = OPT_JUMP;
        insn[i].op[0] = i + insn[i].op[0]; insn[i].opt[0] = OPT_JUMP;
        insn[i].op[1] = 1; insn[i].opt[1] = OPT_CONST;
        insn[i].op[1] = 1; insn[i].opt[1] = OPT_CONST;
        insn[i].type |= IT_BRANCH | IT_VOLATILE;
        insn[i].type |= IT_BRANCH | IT_VOLATILE;
      } else {
      } else {
        i--;
 
        /* repair params */
 
        insn[i].op[2] = insn[i].op[1]; insn[i].opt[2] = insn[i].opt[1] & ~OPT_DEST;
 
        insn[i].op[1] = insn[i].op[0]; insn[i].opt[1] = insn[i].opt[0] & ~OPT_DEST;
 
        insn[i].op[0] = FLAG_REG; insn[i].opt[0] = OPT_DEST | OPT_REGISTER;
 
        insn[i].opt[3] = OPT_NONE;
 
        insn[i].type |= IT_COND;
 
        if (f) negate_conditional (&insn[i]);
 
        i++;
 
        change_insn_type (&insn[i], II_BF);
        change_insn_type (&insn[i], II_BF);
        insn[i].op[0] = i + insn[i].op[0]; insn[i].opt[0] = OPT_JUMP;
        insn[i].op[0] = i + insn[i].op[0]; insn[i].opt[0] = OPT_JUMP;
        insn[i].op[1] = FLAG_REG; insn[i].opt[1] = OPT_REGISTER;
        insn[i].op[1] = FLAG_REG; insn[i].opt[1] = OPT_REGISTER;
        insn[i].type |= IT_BRANCH | IT_VOLATILE;
        insn[i].type |= IT_BRANCH | IT_VOLATILE;
 
        if (f) insn[i].type |= IT_FLAG1;
      }
      }
    } else {
    } else {
      insn[i].index = -1;
      insn[i].index = -1;
      for (j = 0; j < sizeof (conv) / sizeof (cuc_conv); j++)
      for (j = 0; j < sizeof (conv) / sizeof (cuc_conv); j++)
        if (strcmp (conv[j].from, name) == 0) {
        if (strcmp (conv[j].from, name) == 0) {
Line 470... Line 474...
      if (strcmp (name, "l.movhi") == 0) {
      if (strcmp (name, "l.movhi") == 0) {
        insn[i].op[1] <<= 16;
        insn[i].op[1] <<= 16;
        insn[i].op[2] = 0;
        insn[i].op[2] = 0;
        insn[i].opt[2] = OPT_CONST;
        insn[i].opt[2] = OPT_CONST;
      }
      }
 
      if (insn[i].index == II_SFEQ || insn[i].index == II_SFNE
 
       || insn[i].index == II_SFLE || insn[i].index == II_SFGT
 
       || insn[i].index == II_SFGE || insn[i].index == II_SFLT) {
 
        /* repair params */
 
        insn[i].op[2] = insn[i].op[1]; insn[i].opt[2] = insn[i].opt[1] & ~OPT_DEST;
 
        insn[i].op[1] = insn[i].op[0]; insn[i].opt[1] = insn[i].opt[0] & ~OPT_DEST;
 
        insn[i].op[0] = FLAG_REG; insn[i].opt[0] = OPT_DEST | OPT_REGISTER;
 
        insn[i].opt[3] = OPT_NONE;
 
        insn[i].type |= IT_COND;
 
      }
      if (insn[i].index < 0 || insn[i].index == II_NOP && insn[i].op[0] != 0) {
      if (insn[i].index < 0 || insn[i].index == II_NOP && insn[i].op[0] != 0) {
        cucdebug (1, "Instruction #%i: \"%s\" not supported (2).\n", i, name);
        cucdebug (1, "Instruction #%i: \"%s\" not supported (2).\n", i, name);
        log ("Instruction #%i: \"%s\" not supported (2).\n", i, name);
        log ("Instruction #%i: \"%s\" not supported (2).\n", i, name);
        return 1;
        return 1;
      }
      }

powered by: WebSVN 2.1.0

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