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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [or1ksim/] [cuc/] [bb.c] - Diff between revs 19 and 82

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

Rev 19 Rev 82
Line 180... Line 180...
void detect_bb (cuc_func *f)
void detect_bb (cuc_func *f)
{
{
  int i, j, end_bb = 0, eb = 0;
  int i, j, end_bb = 0, eb = 0;
 
 
  /* Mark block starts/ends */
  /* Mark block starts/ends */
  for (i = 0; i < num_insn; i++) {
  for (i = 0; i < num_insn; i++)
    if (end_bb) insn[i].type |= IT_BBSTART;
    {
 
      insn[i].type |= end_bb ? IT_BBSTART : 0;
 
 
    end_bb = 0;
    end_bb = 0;
    if (insn[i].type & IT_BRANCH) {
 
 
      if (insn[i].type & IT_BRANCH)
 
        {
      int jt = insn[i].op[0];
      int jt = insn[i].op[0];
      insn[i].type |= IT_BBEND;
      insn[i].type |= IT_BBEND;
      end_bb = 1;
      end_bb = 1;
      if (jt < 0 || jt >= num_insn) {
 
        fprintf (stderr, "Instruction #%i:Jump out of function '%s'.\n", i, insn[i].disasm);
          if (jt < 0 || jt >= num_insn)
 
            {
 
              fprintf (stderr, "Instruction #%i:Jump out of function '%s'.\n",
 
                       i, insn[i].disasm);
        exit (1);
        exit (1);
      }
      }
      if (jt > 0) insn[jt - 1].type |= IT_BBEND;
 
 
          if (jt > 0)
 
            {
 
              insn[jt - 1].type |= IT_BBEND;
 
            }
 
 
      insn[jt].type |= IT_BBSTART;
      insn[jt].type |= IT_BBSTART;
    }
    }
  }
  }
 
 
  /* Initialize bb array */
  /* Initialize bb array */
  insn[0].type |= IT_BBSTART;
  insn[0].type |= IT_BBSTART;
 
  if (num_insn > 0)
 
    {
  insn[num_insn - 1].type |= IT_BBEND;
  insn[num_insn - 1].type |= IT_BBEND;
 
    }
  f->num_bb = 0;
  f->num_bb = 0;
  for (i = 0; i < num_insn; i++) {
  for (i = 0; i < num_insn; i++) {
    if (insn[i].type & IT_BBSTART) {
    if (insn[i].type & IT_BBSTART) {
      f->bb[f->num_bb].first = i;
      f->bb[f->num_bb].first = i;
      f->bb[f->num_bb].cnt = 0;
      f->bb[f->num_bb].cnt = 0;
Line 1079... Line 1094...
    for (i = 0; i < f->bb[b].ninsn; i++)
    for (i = 0; i < f->bb[b].ninsn; i++)
      if (f->bb[b].insn[i].type & IT_UNUSED) change_insn_type (&f->bb[b].insn[i], II_NOP);
      if (f->bb[b].insn[i].type & IT_UNUSED) change_insn_type (&f->bb[b].insn[i], II_NOP);
 
 
  /* SSAs with final register value are marked as outputs */
  /* SSAs with final register value are marked as outputs */
  assert (f->bb[f->num_bb - 1].next[0] == BBID_END);
  assert (f->bb[f->num_bb - 1].next[0] == BBID_END);
  for (i = 0; i < MAX_REGS; i++) if (!caller_saved[i]) {
  for (i = 0; i < MAX_REGS; i++)
    int t = f->bb[f->num_bb - 1].last_used_reg[i];
    {
    /* Mark them volatile, so optimizer does not remove them */
      if (!caller_saved[i])
    if (t >= 0) f->bb[REF_BB(t)].insn[REF_I(t)].type |= IT_OUTPUT;
 
  }
 
  {
  {
    int t = f->bb[f->num_bb - 1].last_used_reg[i];
    int t = f->bb[f->num_bb - 1].last_used_reg[i];
    /* Mark them volatile, so optimizer does not remove them */
    /* Mark them volatile, so optimizer does not remove them */
    if (t >= 0) f->bb[REF_BB(t)].insn[REF_I(t)].type |= IT_OUTPUT;
          if (t >= 0)
 
            {
 
              f->bb[REF_BB(t)].insn[REF_I(t)].type |= IT_OUTPUT;
 
            }
 
        }
  }
  }
}
}
 
 
/* split the BB, based on the group numbers in .tmp */
/* split the BB, based on the group numbers in .tmp */
void expand_bb (cuc_func *f, int b)
void expand_bb (cuc_func *f, int b)

powered by: WebSVN 2.1.0

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