Quick Search:

Mode

Context

Displaying 0 lines of context. None | Less | More | Full

Other Diffs

Ignore

Blank Lines Whitespace: Expand:

Diff

1.17
 
1.18
 
MAIN:ragge:20110705200419
 
local2.c
     
 !
_>143 -static int
 144 -mixtypes(NODE *p, NODE *q)
 145 -{
 146 -        TWORD tp, tq;
 147 -
 148 -        tp = p->n_type;
 149 -        tq = q->n_type;
 150 -
 151 -        return( (tp==FLOAT || tp==DOUBLE) !=
 152 -                (tq==FLOAT || tq==DOUBLE) );
 153 -}
 154 -
     
 !
<> 277+ * Assign a constant from p to q.  Both are expected to be leaves by now.
  278+ * This is for 64-bit integers.
  279+ */
  280+static void
  281+casg64(NODE *p)
  282+{
  283+        NODE *l, *r;
  284+        char *str;
  285+        int mneg = 1;
  286+        
  287+        l = p->n_left;
  288+        r = p->n_right;
  289+
  290+#ifdef PCC_DEBUG
  291+        if (r->n_op != ICON)
  292+                comperr("casg");
  293+#endif
  294+        if (r->n_name[0] != '\0') {
  295+                /* named constant, nothing to do */
  296+                str = "movq\tAR,AL";
  297+                mneg = 0;
  298+        } else if (r->n_lval == 0) {
  299+                str = "clrq\tAL";
  300+                mneg = 0;
  301+        } else if (r->n_lval < 0) {
  302+                if (r->n_lval >= -63) {
  303+                        r->n_lval = -r->n_lval;
  304+                        str = "mnegl\tAR,AL";
  305+                } else if (r->n_lval >= -128) {
  306+                        str = "cvtbl\tAR,AL";
  307+                } else if (r->n_lval >= -32768) {
  308+                        str = "cvtwl\tAR,AL";
  309+                } else if (r->n_lval >= -4294967296LL) {
  310+                        str = "movl\tAR,AL";
  311+                } else {
  312+                        str = "movq\tAR,AL";
  313+                        mneg = 0;
  314+                }
  315+        } else {
  316+                mneg = 0;
  317+                if (r->n_lval <= 63 || r->n_lval > 4294967295) {
  318+                        str = "movq\tAR,AL";
  319+                } else if (r->n_lval <= 255) {
  320+                        str = "movzbl\tAR,AL\n\tclrl\tUL";
  321+                } else if (r->n_lval <= 65535) {
  322+                        str = "movzwl\tAR,AL\n\tclrl\tUL";
  323+                } else /* if (r->n_lval <= 4294967295) */ {
  324+                        str = "movl\tAR,AL\n\tclrl\tUL";
  325+                }
  326+        }
  327+        expand(p, FOREFF, str);
  328+        if (mneg)
  329+                expand(p, FOREFF, "\tmnegl $-1,UL\n");
  330+}
  331+
  332+/*
  333+ * Assign a constant from p to q.  Both are expected to be leaves by now.
  334+ * This is only for 32-bit integer types.
  335+ */
  336+static void
  337+casg(NODE *p)
  338+{
  339+        NODE *l, *r;
  340+        char *str;
  341+        
  342+        l = p->n_left;
  343+        r = p->n_right;
  344+
  345+#ifdef PCC_DEBUG
  346+        if (r->n_op != ICON)
  347+                comperr("casg");
  348+#endif
  349+        if (r->n_name[0] != '\0') {
  350+                /* named constant, nothing to do */
  351+                str = "movZL\tAR,AL";
  352+        } else if (r->n_lval == 0) {
  353+                str = "clrZL\tAL";
  354+        } else if (r->n_lval < 0) {
  355+                if (r->n_lval >= -63) {
  356+                        r->n_lval = -r->n_lval;
  357+                        str = "mnegZL\tAR,AL";
  358+                } else if (r->n_lval >= -128) {
  359+                        str = "cvtbZL\tAR,AL";
  360+                } else if (r->n_lval >= -32768) {
  361+                        str = "cvtwZL\tAR,AL";
  362+                } else
  363+                        str = "movZL\tAR,AL";
  364+        } else {
  365+                if (r->n_lval <= 63 || r->n_lval > 65535) {
  366+                        str = "movZL\tAR,AL";
  367+                } else if (r->n_lval <= 255) {
  368+                        str = "movzbZL\tAR,AL";
  369+                } else /* if (r->n_lval <= 65535) */ {
  370+                        str = "movzwZL\tAR,AL";
  371+                }
  372+        }
  373+        expand(p, FOREFF, str);
  374+}
  375+
  376+/*
     
 !
<>343 -zzzcode( p, c ) register NODE *p; {
  431+zzzcode(NODE *p, int c)
  432+{
  433+        NODE *l, *r;
     
 !
<>345 -        int val;
     
 !
<>347 -        switch( c ){
     
 !
<> 437+        switch (c) {
     
 !
<>357 -        case 'A':
 358 -                {
 359 -                register NODE *l, *r;
 360 -
 361 -                if (xdebug) e2print(p, 0, &val, &val);
 362 -                r = getlr(p, 'R');
 363 -                if (optype(p->n_op) == LTYPE || p->n_op == UMUL) {
 364 -                        l = resc;
 365 -                        l->n_type = (r->n_type==FLOAT || r->n_type==DOUBLE ? DOUBLE : INT);
 366 -                } else
 367 -                        l = getlr(p, 'L');
 368 -                if (r->n_op == ICON  && r->n_name[0] == '\0') {
 369 -                        if (r->n_lval == 0) {
 370 -                                printf("clr");
 371 -                                prtype(l);
 372 -                                printf("        ");
 373 -                                adrput(stdout, l);
 374 -                                return;
 375 -                        }
 376 -                        if (r->n_lval < 0 && r->n_lval >= -63) {
 377 -                                printf("mneg");
 378 -                                prtype(l);
 379 -                                r->n_lval = -r->n_lval;
 380 -                                goto ops;
 381 -                        }
 382 -                        r->n_type = (r->n_lval < 0 ?
 383 -                                        (r->n_lval >= -128 ? CHAR
 384 -                                        : (r->n_lval >= -32768 ? SHORT
 385 -                                        : INT )) : r->n_type);
 386 -                        r->n_type = (r->n_lval >= 0 ?
 387 -                                        (r->n_lval <= 63 ? INT
 388 -                                        : ( r->n_lval <= 127 ? CHAR
 389 -                                        : (r->n_lval <= 255 ? UCHAR
 390 -                                        : (r->n_lval <= 32767 ? SHORT
 391 -                                        : (r->n_lval <= 65535 ? USHORT
 392 -                                        : INT ))))) : r->n_type );
 393 -                        }
 394 -                if (l->n_op == REG && l->n_type != FLOAT && l->n_type != DOUBLE)
 395 -                        l->n_type = INT;
 396 -                if (!mixtypes(l,r))
 397 -                        {
 398 -                        if (tlen(l) == tlen(r))
 399 -                                {
 400 -                                printf("mov");
 401 -                                prtype(l);
 402 -                                goto ops;
 403 -                                }
 404 -                        else if (tlen(l) > tlen(r) && ISUNSIGNED(r->n_type))
 405 -                                {
 406 -                                printf("movz");
 407 -                                }
 408 -                        else
 409 -                                {
 410 -                                printf("cvt");
 411 -                                }
 412 -                        }
  446+        case 'A': /* Assign a constant directly to a memory position */
  447+                printf("\t");
  448+                if (p->n_type < LONG || ISPTR(p->n_type))
  449+                        casg(p);
     
 !
<>414 -                        {
 415 -                        printf("cvt");
 416 -                        }
 417 -                prtype(r);
 418 -                prtype(l);
 419 -        ops:
 420 -                printf("        ");
 421 -                adrput(stdout, r);
 422 -                printf(",");
 423 -                adrput(stdout, l);
 424 -                return;
 425 -                }
  451+                        casg64(p);
  452+                printf("\n");
  453+                break;
     
 !
<>536 -                        register NODE *l, *r;
     
 !
<>594 -                }
     
 !
<_ 622+}
FishEye: Open Source License registered to PCC.
Your maintenance has expired. You can renew your license at http://www.atlassian.com/fisheye/renew
Atlassian FishEye, CVS analysis. (Version:1.6.3 Build:build-336 2008-11-04) - Administration - Page generated 2014-10-02 10:25 +0200