예제 #1
0
파일: glue.c 프로젝트: ruedagato/arqui
/*-----------------------------------------------------------------*/
static void
pic14emitOverlay (struct dbuf_s * aBuf)
{
        set *ovrset;

        /*  if (!elementsInSet (ovrSetSets))*/

        /* the hack below, fixes translates for devices which
        * only have udata_shr memory */
        dbuf_printf (aBuf, "%s\t%s\n",
                (elementsInSet(ovrSetSets)?"":";"),
                port->mem.overlay_name);

        /* for each of the sets in the overlay segment do */
        for (ovrset = setFirstItem (ovrSetSets); ovrset;
        ovrset = setNextItem (ovrSetSets))
        {

                symbol *sym;

                if (elementsInSet (ovrset))
                {
                /* this dummy area is used to fool the assembler
                otherwise the assembler will append each of these
                declarations into one chunk and will not overlay
                        sad but true */

                        /* I don't think this applies to us. We are using gpasm.  CRF */

                        dbuf_printf (aBuf, ";\t.area _DUMMY\n");
                        /* output the area informtion */
                        dbuf_printf (aBuf, ";\t.area\t%s\n", port->mem.overlay_name);   /* MOF */
                }

                for (sym = setFirstItem (ovrset); sym;
                sym = setNextItem (ovrset))
                {

                        /* if extern then do nothing */
                        if (IS_EXTERN (sym->etype))
                                continue;

                                /* if allocation required check is needed
                                then check if the symbol really requires
                        allocation only for local variables */
                        if (!IS_AGGREGATE (sym->type) &&
                                !(sym->_isparm && !IS_REGPARM (sym->etype))
                                && !sym->allocreq && sym->level)
                                continue;

                                /* if global variable & not static or extern
                        and addPublics allowed then add it to the public set */
                        if ((sym->_isparm && !IS_REGPARM (sym->etype))
                                && !IS_STATIC (sym->etype))
                                addSetHead (&publics, sym);

                                /* if extern then do nothing or is a function
                        then do nothing */
                        if (IS_FUNC (sym->type))
                                continue;

                        /* print extra debug info if required */
                        if (options.debug || sym->level == 0)
                        {
                                if (!sym->level)
                                {               /* global */
                                        if (IS_STATIC (sym->etype))
                                                dbuf_printf (aBuf, "F%s_", moduleName); /* scope is file */
                                        else
                                                dbuf_printf (aBuf, "G_");       /* scope is global */
                                }
                                else
                                        /* symbol is local */
                                        dbuf_printf (aBuf, "L%s_",
                                        (sym->localof ? sym->localof->name : "-null-"));
                                dbuf_printf (aBuf, "%s_%d_%d", sym->name, sym->level, sym->block);
                        }

                        /* if is has an absolute address then generate
                        an equate for this no need to allocate space */
                        if (SPEC_ABSA (sym->etype))
                        {

                                if (options.debug || sym->level == 0)
                                        dbuf_printf (aBuf, " == 0x%04x\n", SPEC_ADDR (sym->etype));

                                dbuf_printf (aBuf, "%s\t=\t0x%04x\n",
                                        sym->rname,
                                        SPEC_ADDR (sym->etype));
                        }
                        else
                        {
                                if (options.debug || sym->level == 0)
                                        dbuf_printf (aBuf, "==.\n");

                                /* allocate space */
                                dbuf_printf (aBuf, "%s:\n", sym->rname);
                                dbuf_printf (aBuf, "\t.ds\t0x%04x\n", (unsigned int) getSize (sym->type) & 0xffff);
                        }

                }
        }
}
예제 #2
0
/*-----------------------------------------------------------------*/
void 
computeDataFlow (eBBlock ** ebbs, int count)
{
  int i;
  int change = 1;

  while (change)
    {

      change = 0;

      /* for all blocks */
      for (i = 0; i < count; i++)
	{

	  set *pred;
	  set *oldOut;
	  int firstTime;
	  eBBlock *pBlock;

	  /* if this is the entry block then continue     */
	  /* since entry block can never have any inExprs */
	  if (ebbs[i]->noPath)
	    continue;

	  /* get blocks that can come to this block */
	  pred = edgesTo (ebbs[i]);

	  /* make a copy of the outExpressions : to be */
	  /* used for iteration   */
	  oldOut = setFromSet (ebbs[i]->outExprs);
	  setToNull ((void **) &ebbs[i]->inDefs);

	  /* indefitions are easy just merge them by union */
	  /* these are the definitions that can possibly   */
	  /* reach this block                              */
	  firstTime = 1;
	  applyToSet (pred, mergeInDefs, ebbs[i], &firstTime);

	  /* if none of the edges coming to this block */
	  /* dominate this block then add the immediate dominator */
	  /* of this block to the list of predecessors */
	  for (pBlock = setFirstItem (pred); pBlock;
	       pBlock = setNextItem (pred))
	    {
	      if (bitVectBitValue (ebbs[i]->domVect, pBlock->bbnum))
		break;
	    }

	  /* get the immediate dominator and put it there */
	  if (!pBlock)
	    {
	      eBBlock *idom = immedDom (ebbs, ebbs[i]);
	      if (idom)
		addSetHead (&pred, idom);
	    }

	  /* figure out the incoming expressions */
	  /* this is a little more complex       */
	  setToNull ((void **) &ebbs[i]->inExprs);
	  if (optimize.global_cse)
	    {
	      firstTime = 1;
	      applyToSet (pred, mergeInExprs, ebbs[i], &firstTime);
	    }
	  setToNull ((void **) &pred);

	  /* do cse with computeOnly flag set to TRUE */
	  /* this by far the quickest way of computing */
	  cseBBlock (ebbs[i], TRUE, ebbs, count);

	  /* if it change we will need to iterate */
	  change += !isSetsEqualWith (ebbs[i]->outExprs, oldOut, isCseDefEqual);
	}

      if (!change)		/* iterate till no change */
	break;
    }

  return;
}
예제 #3
0
파일: ralloc.c 프로젝트: Trewdbal/cpctelera
/*-----------------------------------------------------------------*/
static symbol *
createStackSpil (symbol * sym)
{
  symbol *sloc = NULL;
  struct dbuf_s dbuf;

  D (D_ALLOC, ("createStackSpil: for sym %p %s\n", sym, sym->name));

  /* first go try and find a free one that is already
     existing on the stack */
  if (applyToSet (_G.stackSpil, isFreeSTM8, &sloc, sym))
    {
      /* found a free one : just update & return */
      sym->usl.spillLoc = sloc;
      sym->stackSpil = 1;
      sloc->isFree = 0;
      addSetHead (&sloc->usl.itmpStack, sym);
      D (D_ALLOC, ("createStackSpil: found existing\n"));
      return sym;
    }

  /* could not then have to create one , this is the hard part
     we need to allocate this on the stack : this is really a
     hack!! but cannot think of anything better at this time */

  dbuf_init (&dbuf, 128);
  dbuf_printf (&dbuf, "sloc%d", _G.slocNum++);
  sloc = newiTemp (dbuf_c_str (&dbuf));
  dbuf_destroy (&dbuf);

  /* set the type to the spilling symbol */
  sloc->type = copyLinkChain (sym->type);
  sloc->etype = getSpec (sloc->type);
  SPEC_SCLS (sloc->etype) = S_AUTO;
  SPEC_EXTR (sloc->etype) = 0;
  SPEC_STAT (sloc->etype) = 0;
  SPEC_VOLATILE (sloc->etype) = 0;

  allocLocal (sloc);

  sloc->isref = 1;              /* to prevent compiler warning */

  wassertl (currFunc, "Local variable used outside of function.");

  /* if it is on the stack then update the stack */
  if (IN_STACK (sloc->etype))
    {
      if (currFunc)
        currFunc->stack += getSize (sloc->type);
      _G.stackExtend += getSize (sloc->type);
    }
  else
    {
      _G.dataExtend += getSize (sloc->type);
    }

  /* add it to the stackSpil set */
  addSetHead (&_G.stackSpil, sloc);
  sym->usl.spillLoc = sloc;
  sym->stackSpil = 1;

  /* add it to the set of itempStack set
     of the spill location */
  addSetHead (&sloc->usl.itmpStack, sym);

  D (D_ALLOC, ("createStackSpil: created new\n"));
  return sym;
}