コード例 #1
0
ファイル: sysprocs.c プロジェクト: segafan/bennugd-monolithic
static int tsize( DCB_TYPEDEF orig )
{
    unsigned int n, total ;

    switch ( orig.BaseType[0] )
    {
        case TYPE_ARRAY:
            return orig.Count[0] * tsize( treduce( orig ) ) ;

        case TYPE_POINTER:
        case TYPE_STRING:
        case TYPE_DWORD:
        case TYPE_FLOAT:
        case TYPE_INT:
            return 4 ;

        case TYPE_WORD:
        case TYPE_SHORT:
            return 2 ;

        case TYPE_BYTE:
        case TYPE_SBYTE:
        case TYPE_CHAR:
            return 1 ;

        case TYPE_STRUCT:
            total = 0 ;
            for ( n = 0; n < dcb.varspace[orig.Members].NVars; n++ )
                total += tsize( dcb.varspace_vars[orig.Members][n].Type ) ;
            return total ;

        default:
            return 0 ;
    }
}
コード例 #2
0
ファイル: sqrt.c プロジェクト: bapt/heirloom-doctools
void
sqrt(int p2) {
#ifndef NEQN
	float nps;

	nps = (int)(EFFPS(((eht[p2]*9)/10+(resolution/POINT-1))/(resolution/POINT)));
#endif /* NEQN */
	yyval.token = p2;
#ifndef NEQN
	eht[yyval.token] = VERT(EM(1.2, nps));
	if(dbg)printf(".\tsqrt: S%d <- S%d;b=%g, h=%g\n", 
		yyval.token, p2, ebase[yyval.token], eht[yyval.token]);
	if (ital(rfont[yyval.token]))
		printf(".as %d \\|\n", yyval.token);
#endif /* NEQN */
	nrwid(p2, ps, p2);
#ifndef NEQN
	printf(".ds %d \\v'%gp'\\s%s\\v'-.2m'\\(sr\\l'\\n(%du\\(rn'\\v'.2m'\\s%s", 
		yyval.token, ebase[p2], tsize(nps), p2, tsize(ps));
	printf("\\v'%gp'\\h'-\\n(%du'\\*(%d\n", -ebase[p2], p2, p2);
	lfont[yyval.token] = ROM;
#else /* NEQN */
	printf(".ds %d \\v'%du'\\e\\L'%du'\\l'\\n(%du'",
		p2, ebase[p2], -eht[p2], p2);
	printf("\\v'%du'\\h'-\\n(%du'\\*(%d\n", eht[p2]-ebase[p2], p2, p2);
	eht[p2] += VERT(1);
	if(dbg)printf(".\tsqrt: S%d <- S%d;b=%d, h=%d\n", 
		p2, p2, ebase[p2], eht[p2]);
#endif /* NEQN */
}
コード例 #3
0
ファイル: code.c プロジェクト: JamesLinus/pcc
/* setup struct parameter
 * push the registers out to memory
 * used by bfcode() */
static void
param_struct(struct symtab *sym, int *regp)
{
	int reg = *regp;
	NODE *p, *q;
	int navail;
	int sz;
	int off;
	int num;
	int i;

	navail = nargregs - (reg - A0);
	sz = tsize(sym->stype, sym->sdf, sym->sap) / SZINT;
	off = ARGINIT/SZINT + (reg - A0);
	num = sz > navail ? navail : sz;
	for (i = 0; i < num; i++) {
		q = block(REG, NIL, NIL, INT, 0, 0);
		q->n_rval = reg++;
		p = block(REG, NIL, NIL, INT, 0, 0);
		p->n_rval = FP;
		p = block(PLUS, p, bcon(4*off++), INT, 0, 0);
		p = block(UMUL, p, NIL, INT, 0, 0);
		p = buildtree(ASSIGN, p, q);
		ecomp(p);
	}

	*regp = reg;
}
コード例 #4
0
ファイル: code.c プロジェクト: stqism/DEMOS
efcode(){
	/* code for the end of a function */

	if( strftn ){  /* copy output (in r0) to caller */
		register struct symtab *p;
		register int stlab;
		register int count;
		int size;

		p = &stab[curftn];

		deflab( retlab );

		stlab = getlab();
		printf( "	mov	$L%d,r1\n", stlab );
		size = tsize( DECREF(p->stype), p->dimoff, p->sizoff ) / SZCHAR;
		count = size/2;
		while( count-- ) {
			printf( "	mov	(r0)+,(r1)+\n" );
			}
		printf( "	mov	$L%d,r0\n", stlab );
		printf( "	.bss\nL%d:	.=.+%d.\n	.text\n", stlab, size );
		/* turn off strftn flag, so return sequence will be generated */
		strftn = 0;
		}
	branch( retlab );
	p2bend();
	}
コード例 #5
0
ファイル: gcc_compat.c プロジェクト: pauley/pcc
/*
 * Fixup struct/unions depending on attributes.
 */
void
gcc_tcattrfix(NODE *p)
{
    struct symtab *sp;
    struct attr *ap;
    int sz, coff, csz, al;

    if ((ap = attr_find(p->n_ap, GCC_ATYP_PACKED)) == NULL)
        return; /* nothing to fix */

    al = ap->iarg(0);

    /* Must repack struct */
    coff = csz = 0;
    for (sp = strmemb(ap); sp; sp = sp->snext) {
        if (sp->sclass & FIELD)
            sz = sp->sclass&FLDSIZ;
        else
            sz = (int)tsize(sp->stype, sp->sdf, sp->sap);
        SETOFF(sz, al);
        sp->soffset = coff;
        coff += sz;
        if (coff > csz)
            csz = coff;
        if (p->n_type == UNIONTY)
            coff = 0;
    }
    SETOFF(csz, al); /* Roundup to whatever */

    ap = attr_find(p->n_ap, ATTR_BASETYP);
    ap->atypsz = csz;
    ap->aalign = al;
}
コード例 #6
0
ファイル: code.c プロジェクト: MoochMcGee/pcc-optimized
/* called by moveargs() */
static NODE *
pusharg(NODE *p, int *regp)
{
	NODE *q;
	int sz;

	/* convert to register size, if smaller */
	sz = tsize(p->n_type, p->n_df, p->n_ap);
	if (sz < SZINT)
		p = block(SCONV, p, NIL, INT, 0, 0);

	q = block(REG, NIL, NIL, INT, 0, 0);
	regno(q) = SP;

	if (szty(p->n_type) == 1) {
		++(*regp);
		q = block(MINUSEQ, q, bcon(4), INT, 0, 0);
	} else {
		(*regp) += 2;
		q = block(MINUSEQ, q, bcon(8), INT, 0, 0);
	}

	q = block(UMUL, q, NIL, p->n_type, p->n_df, p->n_ap);

	return buildtree(ASSIGN, q, p);
}
コード例 #7
0
static NODE *
builtin_stdarg_start(const struct bitable *bt, NODE *a)
{
    NODE *p, *q;
    int sz;

    /* must first deal with argument size; use int size */
    p = a->n_right;
    if (p->n_type < INT) {
        sz = (int)(SZINT/tsize(p->n_type, p->n_df, p->n_ap));
    } else
        sz = 1;

    /* do the real job */
    p = buildtree(ADDROF, p, NIL); /* address of last arg */
#ifdef BACKAUTO
    p = optim(buildtree(PLUS, p, bcon(sz))); /* add one to it (next arg) */
#else
    p = optim(buildtree(MINUS, p, bcon(sz))); /* add one to it (next arg) */
#endif
    q = block(NAME, NIL, NIL, PTR+VOID, 0, 0); /* create cast node */
    q = buildtree(CAST, q, p); /* cast to void * (for assignment) */
    p = q->n_right;
    nfree(q->n_left);
    nfree(q);
    p = buildtree(ASSIGN, a->n_left, p); /* assign to ap */
    nfree(a);
    return p;
}
コード例 #8
0
ファイル: code.c プロジェクト: fhector/helenOS-0.5-Hector
/*
 * AMD64 parameter classification.
 */
static int
argtyp(TWORD t, union dimfun *df, struct attr *ap)
{
	int cl = 0;

	if (t <= ULONG || ISPTR(t) || t == BOOL) {
		cl = ngpr < 6 ? INTEGER : INTMEM;
	} else if (t == FLOAT || t == DOUBLE || t == FIMAG || t == IMAG) {
		cl = nsse < 8 ? SSE : SSEMEM;
	} else if (t == LDOUBLE || t == LIMAG) {
		cl = X87; /* XXX */
	} else if (t == STRTY || t == UNIONTY) {
		int sz = tsize(t, df, ap);

		if (sz <= 2*SZLONG && attr_find(ap, ATTR_COMPLEX) != NULL) {
			cl = nsse < 7 ? STRCPX : STRMEM;
		} else if (sz > 2*SZLONG || ((sz+SZLONG)/SZLONG)+ngpr > 6 ||
		    attr_find(ap, GCC_ATYP_PACKED) != NULL)
			cl = STRMEM;
		else
			cl = STRREG;
	} else
		cerror("FIXME: classify");
	return cl;
}
コード例 #9
0
static NODE *
builtin_va_arg(const struct bitable *bt, NODE *a)
{
    NODE *p, *q, *r, *rv;
    int sz, nodnum;

    /* create a copy to a temp node of current ap */
    p = ccopy(a->n_left);
    q = tempnode(0, p->n_type, p->n_df, p->n_ap);
    nodnum = regno(q);
    rv = buildtree(ASSIGN, q, p);

    r = a->n_right;
    sz = (int)tsize(r->n_type, r->n_df, r->n_ap)/SZCHAR;
    /* add one to ap */
#ifdef BACKAUTO
    rv = buildtree(COMOP, rv , buildtree(PLUSEQ, a->n_left, bcon(sz)));
#else
#error fix wrong eval order in builtin_va_arg
    ecomp(buildtree(MINUSEQ, a->n_left, bcon(sz)));
#endif

    nfree(a->n_right);
    nfree(a);
    r = tempnode(nodnum, INCREF(r->n_type), r->n_df, r->n_ap);
    return buildtree(COMOP, rv, buildtree(UMUL, r, NIL));

}
コード例 #10
0
ファイル: local.c プロジェクト: MoochMcGee/pcc-optimized
/*
 * va_start(ap, last) implementation.
 *
 * f is the NAME node for this builtin function.
 * a is the argument list containing:
 *	   CM
 *	ap   last
 *
 * It turns out that this is easy on MIPS.  Just write the
 * argument registers to the stack in va_arg_start() and
 * use the traditional method of walking the stackframe.
 */
NODE *
mips_builtin_stdarg_start(NODE *f, NODE *a, TWORD t)
{
	NODE *p, *q;
	int sz = 1;

	/* check num args and type */
	if (a == NULL || a->n_op != CM || a->n_left->n_op == CM ||
	    !ISPTR(a->n_left->n_type))
		goto bad;

	/* must first deal with argument size; use int size */
	p = a->n_right;
	if (p->n_type < INT) {
		/* round up to word */
		sz = SZINT / tsize(p->n_type, p->n_df, p->n_ap);
	}

	p = buildtree(ADDROF, p, NIL);	/* address of last arg */
	p = optim(buildtree(PLUS, p, bcon(sz)));
	q = block(NAME, NIL, NIL, PTR+VOID, 0, 0);
	q = buildtree(CAST, q, p);
	p = q->n_right;
	nfree(q->n_left);
	nfree(q);
	p = buildtree(ASSIGN, a->n_left, p);
	tfree(f);
	nfree(a);

	return p;

bad:
	uerror("bad argument to __builtin_stdarg_start");
	return bcon(0);
}
コード例 #11
0
ファイル: code.c プロジェクト: paploo/pcc
/*
 * code for the end of a function
 * deals with struct return here
 */
void
efcode(void)
{
	NODE *p, *q;
	int sz;

	if (cftnsp->stype != STRTY+FTN && cftnsp->stype != UNIONTY+FTN)
		return;
	/* address of return struct is in %ret0 */
	/* create a call to memcpy() */
	/* will get the result in %ret0 */
	p = block(REG, NIL, NIL, CHAR+PTR, 0, 0);
	p->n_rval = RET0;
	q = block(OREG, NIL, NIL, CHAR+PTR, 0, 0);
	q->n_rval = FP;
	q->n_lval = 8; /* return buffer offset */
	p = block(CM, q, p, INT, 0, 0);
	sz = (tsize(STRTY, cftnsp->sdf, cftnsp->ssue)+SZCHAR-1)/SZCHAR;
	p = block(CM, p, bcon(sz), INT, 0, 0);
	p->n_right->n_name = "";
	p = block(CALL, bcon(0), p, CHAR+PTR, 0, 0);
	p->n_left->n_name = "memcpy";
	p = clocal(p);
	send_passt(IP_NODE, p);
}
コード例 #12
0
ファイル: local.c プロジェクト: MoochMcGee/pcc-optimized
void
myp2tree(NODE *p)
{
	struct symtab *sp;

	if (p->n_op != FCON) 
		return;

	/* Write float constants to memory */
 
	sp = IALLOC(sizeof(struct symtab));
	sp->sclass = STATIC;
	sp->sap = 0;
	sp->slevel = 1; /* fake numeric label */
	sp->soffset = getlab();
	sp->sflags = 0;
	sp->stype = p->n_type;
	sp->squal = (CON >> TSHIFT);

	defloc(sp);
	ninval(0, tsize(sp->stype, sp->sdf, sp->sap), p);

	p->n_op = NAME;
	p->n_lval = 0;
	p->n_sp = sp;

}
コード例 #13
0
wxSize wxChoice::DoGetSizeFromTextSize(int xlen, int ylen) const
{
    int cHeight = GetCharHeight();

    // We are interested in the difference of sizes between the whole control
    // and its child part. I.e. arrow, separators, etc.
    wxSize tsize(xlen, 0);

    // FIXME-VC6: Only VC6 needs this guard, see WINVER definition in
    //            include/wx/msw/wrapwin.h
#if defined(WINVER) && WINVER >= 0x0500
    WinStruct<COMBOBOXINFO> info;
    if ( MSWGetComboBoxInfo(&info) )
    {
        tsize.x += info.rcItem.left + info.rcButton.right - info.rcItem.right
                    + info.rcItem.left + 3; // right and extra margins
    }
    else // Just use some rough approximation.
#endif // WINVER >= 0x0500
    {
        tsize.x += 4*cHeight;
    }

    // set height on our own
    if( HasFlag( wxCB_SIMPLE ) )
        tsize.y = SetHeightSimpleComboBox(GetCount());
    else
        tsize.y = EDIT_HEIGHT_FROM_CHAR_HEIGHT(cHeight);

    // Perhaps the user wants something different from CharHeight
    if ( ylen > 0 )
        tsize.IncBy(0, ylen - cHeight);

    return tsize;
}
コード例 #14
0
ファイル: code.c プロジェクト: MoochMcGee/pcc-optimized
/* setup struct parameter
 * push the registers out to memory
 * used by bfcode() */
static void
param_struct(struct symtab *sym, int *argofsp)
{
	int argofs = *argofsp;
	NODE *p, *q;
	int navail;
	int sz;
	int off;
	int num;
	int i;

	navail = NARGREGS - argofs;
	sz = tsize(sym->stype, sym->sdf, sym->sap) / SZINT;
	off = ARGINIT/SZINT + argofs;
	num = sz > navail ? navail : sz;
	for (i = 0; i < num; i++) {
		q = block(REG, NIL, NIL, INT, 0, 0);
		regno(q) = R0 + argofs++;
		p = block(REG, NIL, NIL, INT, 0, 0);
		regno(p) = SP;
		p = block(PLUS, p, bcon(4*off++), INT, 0, 0);
		p = block(UMUL, p, NIL, INT, 0, 0);
		p = buildtree(ASSIGN, p, q);
		ecomp(p);
	}

	*argofsp = argofs;
}
コード例 #15
0
ファイル: choice.cpp プロジェクト: chromylei/third_party
wxSize wxChoice::DoGetSizeFromTextSize(int xlen, int ylen) const
{
    wxASSERT_MSG( m_widget, wxS("GetSizeFromTextSize called before creation") );

    // a GtkEntry for wxComboBox and a GtkCellView for wxChoice
    GtkWidget* childPart = gtk_bin_get_child(GTK_BIN(m_widget));

    // Set a as small as possible size for the control, so preferred sizes
    // return "natural" sizes, not taking into account the previous ones (which
    // seems to be GTK+3 behaviour)
    gtk_widget_set_size_request(m_widget, 0, 0);

    // We are interested in the difference of sizes between the whole contol
    // and its child part. I.e. arrow, separators, etc.
    GtkRequisition req;
    gtk_widget_get_preferred_size(childPart, NULL, &req);
    wxSize totalS = GTKGetPreferredSize(m_widget);

    wxSize tsize(xlen + totalS.x - req.width, totalS.y);

    // For a wxChoice, not for wxComboBox, add some margins
    if ( !GTK_IS_ENTRY(childPart) )
        tsize.IncBy(5, 0);

    // Perhaps the user wants something different from CharHeight
    if ( ylen > 0 )
        tsize.IncBy(0, ylen - GetCharHeight());

    return tsize;
}
コード例 #16
0
wxSize wxChoice::DoGetSizeFromTextSize(int xlen, int ylen) const
{
    wxASSERT_MSG( m_widget, wxS("GetSizeFromTextSize called before creation") );

    // a GtkEntry for wxComboBox and a GtkCellView for wxChoice
    GtkWidget* childPart = gtk_bin_get_child(GTK_BIN(m_widget));

    // We are interested in the difference of sizes between the whole contol
    // and its child part. I.e. arrow, separators, etc.
    GtkRequisition req;
    gtk_widget_get_preferred_size(childPart, NULL, &req);
    wxSize totalS = GTKGetPreferredSize(m_widget);

    wxSize tsize(xlen + totalS.x - req.width, totalS.y);

    // For a wxChoice, not for wxComboBox, add some margins
    if ( !GTK_IS_ENTRY(childPart) )
        tsize.IncBy(5, 0);

    // Perhaps the user wants something different from CharHeight
    if ( ylen > 0 )
        tsize.IncBy(0, ylen - GetCharHeight());

    return tsize;
}
コード例 #17
0
ファイル: spinctrl.cpp プロジェクト: 0ryuO/dolphin-avsync
wxSize wxSpinCtrlGTKBase::DoGetSizeFromTextSize(int xlen, int ylen) const
{
    wxASSERT_MSG( m_widget, wxS("GetSizeFromTextSize called before creation") );

    // Set an as small as possible size for the control, so preferred sizes
    // return "natural" sizes, not taking into account the previous ones (which
    // seems to be GTK+3 behaviour)
    gtk_widget_set_size_request(m_widget, 0, 0);

    // Both Gtk+2 and Gtk+3 use current value/range to measure control's width.
    // So, we can't ask Gtk+ for its width. Instead, we used hardcoded values.

    // Returned height is OK
    wxSize totalS = GTKGetPreferredSize(m_widget);

#if GTK_CHECK_VERSION(3,4,0)
    // two buttons in horizontal
    totalS.x = 46 + 15; // margins included
#else
    // two small buttons in vertical
    totalS.x = GetFont().GetPixelSize().y + 13; // margins included
#endif

    wxSize tsize(xlen + totalS.x, totalS.y);

    // Check if the user requested a non-standard height.
    if ( ylen > 0 )
        tsize.IncBy(0, ylen - GetCharHeight());

    return tsize;
}
コード例 #18
0
ファイル: integral.c プロジェクト: bapt/heirloom-doctools
void
setintegral(void) {
	const char *f;

	yyval.token = oalloc();
	f = "\\(is";
#ifndef NEQN
	printf(".ds %d \\s%s\\v'.1m'\\s+4%s\\s-4\\v'-.1m'\\s%s\n", 
		yyval.token, tsize(ps), f, tsize(ps));
	eht[yyval.token] = VERT(EM(1.15, ps+4));
	ebase[yyval.token] = VERT(EM(0.3, ps));
#else /* NEQN */
	printf(".ds %d %s\n", yyval.token, f);
	eht[yyval.token] = VERT(2);
	ebase[yyval.token] = 0;
#endif /* NEQN */
	lfont[yyval.token] = rfont[yyval.token] = ROM;
}
コード例 #19
0
void FlowAnnot::nav_erase( void *pos, void *node)
{
  if ( !(display_level & ctx->display_level))
    return;
  if ( !((FlowNode *) node)->annotv[number])
    return;
  int idx = int( ctx->nav_zoom_factor / ctx->base_zoom_factor * 
		(text_size +4) - 4);
  if ( idx < 0)
    return;
  idx = MIN( idx, DRAW_TYPE_SIZE-1);
  switch ( annot_type) {
    case flow_eAnnotType_OneLine:
      ctx->fdraw->nav_text_erase( ctx,
				  p.nav_z_x + ((FlowPoint *)pos)->nav_z_x - ctx->nav_offset_x, 
				  p.nav_z_y + ((FlowPoint *)pos)->nav_z_y - ctx->nav_offset_y, 
				  ((FlowNode *) node)->annotv[number], 
				  strlen(((FlowNode *) node)->annotv[number]), draw_type, idx, 0,
				  nav_tsize( text_size));
      break;
    case flow_eAnnotType_MultiLine:
    {
      int z_width, z_height;
      int z_x = p.nav_z_x + ((FlowPoint *)pos)->nav_z_x - ctx->nav_offset_x;
      int z_y = p.nav_z_y + ((FlowPoint *)pos)->nav_z_y - ctx->nav_offset_y;
      int len = 0;
      int line_cnt = 0;
      char *line = ((FlowNode *) node)->annotv[number];
      char *s;
      ctx->fdraw->get_text_extent( ctx, "Ag", 2, draw_type, idx, &z_width, &z_height,
				   tsize(text_size));
      for ( s = ((FlowNode *) node)->annotv[number]; *s; s++)
      {
        if ( *s == 10)
	{
	  if ( len) {
	    *s = 0;
            ctx->fdraw->nav_text_erase( ctx, z_x, z_y + line_cnt * z_height, line, 
					len, draw_type, idx, 0,
					nav_tsize( text_size));
	    *s = 10;
	  }
	  len = 0;
	  line = s+1;
	  line_cnt++;
	}
	else
	  len++;
      }
      if ( len)
        ctx->fdraw->nav_text_erase( ctx, z_x, z_y + line_cnt * z_height, line, 
				    len, draw_type, idx, 0,
				    nav_tsize( text_size));
      break;
    }
  }
}
コード例 #20
0
ファイル: local.c プロジェクト: ajinkya93/netbsd-src
/* make a common declaration for id, if reasonable */
void
commdec(struct symtab *q)
{
	int off;

	off = tsize(q->stype, q->sdf, q->ssue);
	off = (off+(SZCHAR-1))/SZCHAR;
	printf("	.comm %s,0%o\n", exname(q->soname), off);
}
コード例 #21
0
ファイル: code.c プロジェクト: rheoli/pcc
/*
 * code for the end of a function
 * deals with struct return here
 * The return value is in (or pointed to by) RETREG.
 */
void
efcode(void)
{
	struct symtab *sp;
	extern int gotnr;
	TWORD t;
	NODE *p, *r, *l;
	int typ, ssz, rno;

	gotnr = 0;	/* new number for next fun */
	sp = cftnsp;
	t = DECREF(sp->stype);
	if (t != STRTY && t != UNIONTY)
		return;

	/* XXX should have one routine for this */
	ngpr = nsse = 0;
	if ((typ = argtyp(t, sp->sdf, sp->sap)) == STRREG || typ == STRCPX) {
		/* Cast to long pointer and move to the registers */
		/* XXX can overrun struct size */
		/* XXX check carefully for SSE members */

		if ((ssz = tsize(t, sp->sdf, sp->sap)) > SZLONG*2)
			cerror("efcode1");

		if (typ == STRCPX) {
			t = DOUBLE;
			rno = XMM0;
		} else {
			t = LONG;
			rno = RAX;
		}
		if (ssz > SZLONG) {
			p = block(REG, NIL, NIL, INCREF(t), 0, 0);
			regno(p) = RAX;
			p = buildtree(UMUL, buildtree(PLUS, p, bcon(1)), NIL);
			ecomp(movtoreg(p, rno+1));
		}
		p = block(REG, NIL, NIL, INCREF(t), 0, 0);
		regno(p) = RAX;
		p = buildtree(UMUL, p, NIL);
		ecomp(movtoreg(p, rno));
	} else if (typ == STRMEM) {
		r = block(REG, NIL, NIL, INCREF(t), sp->sdf, sp->sap);
		regno(r) = RAX;
		r = buildtree(UMUL, r, NIL);
		l = tempnode(stroffset, INCREF(t), sp->sdf, sp->sap);
		l = buildtree(UMUL, l, NIL);
		ecomp(buildtree(ASSIGN, l, r));
		l = block(REG, NIL, NIL, LONG, 0, 0);
		regno(l) = RAX;
		r = tempnode(stroffset, LONG, 0, 0);
		ecomp(buildtree(ASSIGN, l, r));
	} else
		cerror("efcode");
}
コード例 #22
0
ファイル: local.c プロジェクト: MoochMcGee/pcc-optimized
NODE *
mips_builtin_va_arg(NODE *f, NODE *a, TWORD t)
{
	NODE *p, *q, *r;
	int sz, tmpnr;

	/* check num args and type */
	if (a == NULL || a->n_op != CM || a->n_left->n_op == CM ||
	    !ISPTR(a->n_left->n_type) || a->n_right->n_op != TYPE)
		goto bad;

	r = a->n_right;

	/* get type size */
	sz = tsize(r->n_type, r->n_df, r->n_ap) / SZCHAR;
	if (sz < SZINT/SZCHAR) {
		werror("%s%s promoted to int when passed through ...",
			r->n_type & 1 ? "unsigned " : "",
			DEUNSIGN(r->n_type) == SHORT ? "short" : "char");
		sz = SZINT/SZCHAR;
	}

	/* alignment */
	p = tcopy(a->n_left);
	if (sz > SZINT/SZCHAR && r->n_type != UNIONTY && r->n_type != STRTY) {
		p = buildtree(PLUS, p, bcon(7));
		p = block(AND, p, bcon(-8), p->n_type, p->n_df, p->n_ap);
	}

	/* create a copy to a temp node */
	q = tempnode(0, p->n_type, p->n_df, p->n_ap);
	tmpnr = regno(q);
	p = buildtree(ASSIGN, q, p);

	q = tempnode(tmpnr, p->n_type, p->n_df,p->n_ap);
	q = buildtree(PLUS, q, bcon(sz));
	q = buildtree(ASSIGN, a->n_left, q);

	q = buildtree(COMOP, p, q);

	nfree(a->n_right);
	nfree(a);
	nfree(f); 

	p = tempnode(tmpnr, INCREF(r->n_type), r->n_df, r->n_ap);
	p = buildtree(UMUL, p, NIL);
	p = buildtree(COMOP, q, p);

	return p;

bad:
	uerror("bad argument to __builtin_va_arg");
	return bcon(0);
}
コード例 #23
0
ファイル: code.c プロジェクト: rheoli/pcc
/*
 * Called with a function call with arguments as argument.
 * This is done early in buildtree() and only done once.
 * Returns p.
 */
NODE *
funcode(NODE *p)
{
	NODE *l, *r;
	TWORD t;
	int i;

	nsse = ngpr = nrsp = 0;
	/* Check if hidden arg needed */
	/* If so, add it in pass2 */
	if ((l = p->n_left)->n_type == INCREF(FTN)+STRTY ||
	    l->n_type == INCREF(FTN)+UNIONTY) {
		int ssz = tsize(BTYPE(l->n_type), l->n_df, l->n_ap);
		if (ssz > 2*SZLONG)
			ngpr++;
	}

	/* Convert just regs to assign insn's */
	p->n_right = argput(p->n_right);

	/* Must sort arglist so that STASG ends up first */
	/* This avoids registers being clobbered */
	while (argsort(p->n_right))
		;
	/* Check if there are varargs */
	if (nsse || l->n_df == NULL || l->n_df->dfun == NULL) {
		; /* Need RAX */
	} else {
		union arglist *al = l->n_df->dfun;

		for (; al->type != TELLIPSIS; al++) {
			if ((t = al->type) == TNULL)
				return p; /* No need */
			if (ISSOU(BTYPE(t)))
				al++;
			for (i = 0; t > BTMASK; t = DECREF(t))
				if (ISARY(t) || ISFTN(t))
					i++;
			if (i)
				al++;
		}
	}

	/* Always emit number of SSE regs used */
	l = movtoreg(bcon(nsse), RAX);
	if (p->n_right->n_op != CM) {
		p->n_right = block(CM, l, p->n_right, INT, 0, 0);
	} else {
		for (r = p->n_right; r->n_left->n_op == CM; r = r->n_left)
			;
		r->n_left = block(CM, l, r->n_left, INT, 0, 0);
	}
	return p;
}
コード例 #24
0
ファイル: ColorFading.cpp プロジェクト: mrzzzrm/shootet
  void ColorFading::setSize(const geo::IntSize &size)
  {
    IntSize tsize(size);

    if(size.getWidth() < 0)
      tsize.setWidth(gfx::getScreenSize().getWidth());
    if(size.getHeight() < 0)
      tsize.setHeight(gfx::getScreenSize().getHeight());

    image.setSize(tsize);
    image.fill(color);
  }
コード例 #25
0
ファイル: local.c プロジェクト: enukane/netbsd-src
/* make a local common declaration for id, if reasonable */
void
lcommdec(struct symtab *q)
{
	int off;

	off = tsize(q->stype, q->sdf, q->ssue);
	off = (off+(SZCHAR-1))/SZCHAR;
	if (q->slevel == 0)
		printf("	.lcomm %s,0%o\n", exname(q->soname), off);
	else
		printf("	.lcomm " LABFMT ",0%o\n", q->soffset, off);
}
コード例 #26
0
ファイル: over.c プロジェクト: bapt/heirloom-doctools
void
boverb(int p1, int p2) {
	int treg;
#ifndef	NEQN
	float h, b, d;
#else	/* NEQN */
	int h, b, d;
#endif	/* NEQN */

	treg = oalloc();
	yyval.token = p1;
#ifndef NEQN
	d = VERT(EM(0.3, ps));
	h = eht[p1] + eht[p2] + d;
#else /* NEQN */
	d = VERT(1);
	h = eht[p1] + eht[p2];
#endif /* NEQN */
	b = eht[p2] - d;
#ifndef	NEQN
	if(dbg)printf(".\tb:bob: S%d <- S%d over S%d; b=%g, h=%g\n", 
		yyval.token, p1, p2, b, h);
#else	/* NEQN */
	if(dbg)printf(".\tb:bob: S%d <- S%d over S%d; b=%d, h=%d\n", 
		yyval.token, p1, p2, b, h);
#endif	/* NEQN */
	nrwid(p1, ps, p1);
	nrwid(p2, ps, p2);
	printf(".nr %d \\n(%d\n", treg, p1);
	printf(".if \\n(%d>\\n(%d .nr %d \\n(%d\n", p2, treg, treg, p2);
#ifndef NEQN
	printf(".nr %d \\n(%d+\\s%s.5m\\s0\n", treg, treg, tsize(EFFPS(ps)));
	printf(".ds %d \\v'%gp'\\h'\\n(%du-\\n(%du/2u'\\*(%d\\\n", 
		yyval.token, eht[p2]-ebase[p2]-d, treg, p2, p2);
	printf("\\h'-\\n(%du-\\n(%du/2u'\\v'%gp'\\*(%d\\\n", 
		p2, p1, -(eht[p2]-ebase[p2]+d+ebase[p1]), p1);
	printf("\\h'-\\n(%du-\\n(%du/2u+.1m'\\v'%gp'\\l'\\n(%du-.2m'\\h'.1m'\\v'%gp'\n", 
		 treg, p1, ebase[p1]+d, treg, d);
#else /* NEQN */
	printf(".ds %d \\v'%du'\\h'\\n(%du-\\n(%du/2u'\\*(%d\\\n", 
		yyval.token, eht[p2]-ebase[p2]-d, treg, p2, p2);
	printf("\\h'-\\n(%du-\\n(%du/2u'\\v'%du'\\*(%d\\\n", 
		p2, p1, -eht[p2]+ebase[p2]-ebase[p1], p1);
	printf("\\h'-\\n(%du-\\n(%du-2u/2u'\\v'%du'\\l'\\n(%du'\\v'%du'\n", 
		 treg, p1, ebase[p1], treg, d);
#endif /* NEQN */
	ebase[yyval.token] = b;
	eht[yyval.token] = h;
	lfont[yyval.token] = rfont[yyval.token] = 0;
	ofree(p2);
	ofree(treg);
}
コード例 #27
0
ファイル: local.c プロジェクト: MoochMcGee/pcc-optimized
/* make a common declaration for id, if reasonable */
void
defzero(struct symtab *sp)
{
	int off;

	off = tsize(sp->stype, sp->sdf, sp->sap);
	off = (off+(SZCHAR-1))/SZCHAR;
	printf("	.%scomm ", sp->sclass == STATIC ? "l" : "");
	if (sp->slevel == 0)
		printf("%s,0%o\n", sp->soname ? sp->soname : exname(sp->sname), off);
	else
		printf(LABFMT ",0%o\n", sp->soffset, off);
}
コード例 #28
0
ファイル: local.c プロジェクト: ajinkya93/netbsd-src
/*
 * return a node, for structure references, which is suitable for
 * being added to a pointer of type t, in order to be off bits offset
 * into a structure
 * t, d, and s are the type, dimension offset, and sizeoffset
 * For nova, return the type-specific index number which calculation
 * is based on its size. For example, char a[3] would return 3.
 * Be careful about only handling first-level pointers, the following
 * indirections must be fullword.
 */
NODE *
offcon(OFFSZ off, TWORD t, union dimfun *d, struct attr *ap)
{
	register NODE *p;

	if (xdebug)
		printf("offcon: OFFSZ %ld type %x dim %p siz %ld\n",
		    off, t, d, tsize(t, d, ap));

	p = bcon(off/SZINT);
	if (t == INCREF(CHAR) || t == INCREF(UCHAR) || t == INCREF(VOID))
		p->n_lval = off/SZCHAR; /* pointer to char */
	return(p);
}
コード例 #29
0
ファイル: io.c プロジェクト: bapt/heirloom-doctools
void
putout(int p1) {
#ifndef	NEQN
	float before, after;
	if(dbg)printf(".\tanswer <- S%d, h=%g,b=%g\n",p1, eht[p1], ebase[p1]);
#else	/* NEQN */
	int before, after;
	if(dbg)printf(".\tanswer <- S%d, h=%d,b=%d\n",p1, eht[p1], ebase[p1]);
#endif	/* NEQN */
	eqnht = eht[p1];
	printf(".ds %d ", p1);
	/* suppposed to leave room for a subscript or superscript */
#ifndef NEQN
	before = eht[p1] - ebase[p1] - VERT(EM(1.2, ps));
#else /* NEQN */
	before = eht[p1] - ebase[p1] - VERT(3);	/* 3 = 1.5 lines */
#endif /* NEQN */
	if (spaceval != NULL)
		printf("\\x'0-%s'", spaceval);
	else if (before > 0)
#ifndef	NEQN
		printf("\\x'0-%gp'", before);
#else	/* NEQN */
		printf("\\x'0-%du'", before);
#endif	/* NEQN */
	printf("\\f%c\\s%s\\*(%d%s\n",
		gfont, tsize(gsize), p1, ital(rfont[p1]) ? "\\|" : "");
	printf(".ie \\n(.X=0 .as %d \\s\\n(99\n", p1);
	printf(".el .as %d \\s[\\n(99]\n", p1);
	printf(".as %d \\f\\n(98", p1);
#ifndef NEQN
	after = ebase[p1] - VERT(EM(0.2, ps));
#else /* NEQN */
	after = ebase[p1] - VERT(1);
#endif /* NEQN */
	if (spaceval == NULL && after > 0)
#ifndef	NEQN
		printf("\\x'%gp'", after);
#else	/* NEQN */
		printf("\\x'%du'", after);
#endif	/* NEQN */
	putchar('\n');
	eqnreg = p1;
	if (spaceval != NULL) {
		free(spaceval);
		spaceval = NULL;
	}

}
コード例 #30
0
ファイル: combobox.cpp プロジェクト: HanruZhou/wxWidgets
wxSize wxComboBox::DoGetSizeFromTextSize(int xlen, int ylen) const
{
    wxSize tsize( wxChoice::DoGetSizeFromTextSize(xlen, ylen) );

    if ( !HasFlag(wxCB_READONLY) )
    {
        // Add the margins we have previously set
        wxPoint marg( GetMargins() );
        marg.x = wxMax(0, marg.x);
        marg.y = wxMax(0, marg.y);
        tsize.IncBy( marg );
    }

    return tsize;
}