Esempio n. 1
0
File: gen.c Progetto: Godzil/osXdk
void function(sSymbol_t f, sSymbol_t caller[], sSymbol_t callee[], int ncalls) 
{
	int i;

	localsize=offset=tmpsize=nbregs=0; funame=f->x.name;
	for (i=8;i<32;i++) temp[i]->x.name="******";
	for (i = 0; caller[i] && callee[i]; i++) 
	{
		caller[i]->x.name=stringf("(ap),%d",offset);
		caller[i]->x.adrmode='A';
		offset+=caller[i]->type->size;
		if (optimizelevel>1 && callee[i]->sclass==REGISTER && allocreg(callee[i]))
			; /* allocreg ok */
		else 
		{
			callee[i]->x.adrmode=caller[i]->x.adrmode;
			callee[i]->x.name=caller[i]->x.name;
			callee[i]->sclass=AUTO;
		}
	}
	busy=localsize=0; offset=6;
	gencode(caller,callee);
	omit_frame=(i==0 && localsize==6);
	print("%s\n",funame);
	if (optimizelevel>1 && omit_frame && nbregs==0)
		;
	else print("\tENTER(%d,%d)\n",nbregs,localsize);
	if (isstruct(freturn(f->type)))
		print("\tMOVW_DI(op1,(fp),6)\n");
	emitcode();
}
Esempio n. 2
0
void
emitLabel (symbol *tlbl)
{
  if (!tlbl)
    return;
  emitcode ("", "!tlabeldef", labelKey2num (tlbl->key));
  genLine.lineCurr->isLabel = 1;
}
Esempio n. 3
0
File: svg.c Progetto: Melab/gvmt
static void function(Symbol f, Symbol caller[], Symbol callee[], int ncalls) {
    int i, size, varargs;
    Symbol* p;
    for (p = caller; *p; p++)     
        (*p)->x.type = get_type((*p)->type, 0);
    for (p = callee; *p; p++)     
        (*p)->x.type = get_type((*p)->type, 0);
	for (i = 0; callee[i]; i++) {
        Symbol p = callee[i];
        Symbol q = caller[i];
        gvmt_local(p);
        q->sclass = p->sclass = REGISTER;
        q->x.name = p->x.name;
        q->x.type = p->x.type;
    }
//    print("Function %s \\\n", f->x.name);
	//params = stackParameters(caller, callee);
	gencode(caller, callee);
	// framesize = roundup(offset, 4);
	emitcode();
}
Esempio n. 4
0
static void asdl_function(Symbol f, Symbol caller[], Symbol callee[], int ncalls) {
	list_ty codelist = Seq_new(0), save, calleelist = Seq_new(0), callerlist = Seq_new(0);
	int i;

	dopending(f);
	for (i = 0; caller[i] != NULL; i++) {
		asdl_local(caller[i]);
		Seq_addhi(callerlist, to_generic_int(symboluid(caller[i])));
	}
	for (i = 0; callee[i] != NULL; i++) {
		asdl_local(callee[i]);
		Seq_addhi(calleelist, to_generic_int(symboluid(callee[i])));
	}
	save = interfaces;
	interfaces = codelist;
	gencode(caller, callee);
	asdl_segment(CODE);
	emitcode();
	interfaces = save;
	put(rcc_Function(symboluid(f), callerlist, calleelist, ncalls, codelist));
}
Esempio n. 5
0
/*-----------------------------------------------------------------*/
void
genInline (iCode * ic)
{
  char *buf, *bp, *begin;
  bool inComment = FALSE;

  D (emitcode (";", "genInline"));

  genLine.lineElement.isInline += (!options.asmpeep);

  buf = bp = begin = Safe_strdup (IC_INLINE (ic));

  /* Emit each line as a code */
  while (*bp)
    {
      switch (*bp)
        {
        case ';':
          inComment = TRUE;
          ++bp;
          break;

        case '\x87':
        case '\n':
          inComment = FALSE;
          *bp++ = '\0';

          /* Don't emit leading whitespaces */
          while (isspace (*begin))
            ++begin;

          if (*begin)
            emitcode (begin, NULL);

          begin = bp;
          break;

        default:
          /* Add \n for labels, not dirs such as c:\mydir */
          if (!inComment && (*bp == ':') && (isspace ((unsigned char) bp[1])))
            {
              ++bp;
              *bp = '\0';
              ++bp;
              emitcode (begin, NULL);
              begin = bp;
            }
          else
            ++bp;
          break;
        }
    }
  if (begin != bp)
    {
      /* Don't emit leading whitespaces */
      while (isspace (*begin))
        ++begin;

      if (*begin)
        emitcode (begin, NULL);
    }

  Safe_free (buf);

  /* consumed; we can free it here */
  dbuf_free (IC_INLINE (ic));

  genLine.lineElement.isInline -= (!options.asmpeep);
}