Quick Search:

Mode

Context

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

Other Diffs

Ignore

Blank Lines Whitespace: Expand:

Diff

1.16
 
1.17
 
MAIN:ragge:20110702151159
 
local2.c
     
 !
_>122 -tlen(p) NODE *p;
  122+tlen(NODE *p)
     
 !
<>125 -                case CHAR:
 126 -                case UCHAR:
 127 -                        return(1);
  125+        case CHAR:
  126+        case UCHAR:
  127+                return(1);
     
 !
<>129 -                case SHORT:
 130 -                case USHORT:
 131 -                        return(2);
  129+        case SHORT:
  130+        case USHORT:
  131+                return(2);
     
 !
<>133 -                case DOUBLE:
 134 -                case LDOUBLE:
 135 -                case LONGLONG:
 136 -                case ULONGLONG:
 137 -                        return(8);
  133+        case DOUBLE:
  134+        case LONGLONG:
  135+        case ULONGLONG:
  136+                return(8);
     
 !
<>139 -                default:
 140 -                        return(4);
 141 -                }
  138+        default:
  139+                return(4);
  140+        }
     
 !
<>159 -        switch (n->n_type)
 160 -                {
 161 -                case DOUBLE:
 162 -                        printf("d");
 163 -                        return;
  158+        static char pt[] = { 0, 0, 'b', 'b', 'w', 'w', 'l', 'l', 0, 0,
  159+            'q', 'q', 'f', 'd' };
  160+        TWORD t = n->n_type;
     
 !
<>165 -                case FLOAT:
 166 -                        printf("f");
 167 -                        return;
  162+        if (ISPTR(t))
  163+                t = UNSIGNED;
     
 !
<>169 -                case LONG:
 170 -                case ULONG:
 171 -                case INT:
 172 -                case UNSIGNED:
 173 -                        printf("l");
 174 -                        return;
  165+        if (t > DOUBLE || pt[t] == 0)
  166+                comperr("prtype: bad type");
  167+        putchar(pt[t]);
  168+}
     
 !
<>176 -                case SHORT:
 177 -                case USHORT:
 178 -                        printf("w");
 179 -                        return;
  170+/*
  171+ * Emit conversions as given by the following table. Dest is always reg,
  172+ *   if it should be something else let peephole optimizer deal with it.
  173+ *   This code ensures type correctness in 32-bit registers.
  174+ *   XXX is that necessary?
  175+ *
  176+ * From                         To
  177+ *       char   uchar  short  ushort int    uint   ll    ull   float double
  178+ * char  movb   movb   cvtbw  cvtbw  cvtbl  cvtbl  A     A     cvtbf cvtbd
  179+ * uchar movb   movb   movzbw movzbw movzbl movzbl B     B     G     G
  180+ * short movb   movb   movw   movw   cvtwl  cvtwl  C(A)  C(A)  cvtwf cvtwd
  181+ * ushrt movb   movb   movw   movw   movzwl movzwl D(B)  D(B)  H     H
  182+ * int   movb   movb   movw   movw   movl   movl   E     E     cvtlf cvtld
  183+ * uint  movb   movb   movw   movw   movl   movl   F     F     I     I
  184+ * ll    movb   movb   movw   movw   movl   movl   movq  movq  J     K
  185+ * ull   movb   movb   movw   movw   movl   movl   movq  movq  L     M
  186+ * float cvtfb  cvtfb  cvtfw  cvtfw  cvtfl  cvtfl  N     O     movf  cvtfd
  187+ * doubl cvtdb  cvtdb  cvtdw  cvtdw  cvtdl  cvtdl  P     Q     cvtdf movd
  188+ *
  189+ *  A: cvtbl + sign extend
  190+ *  B: movzbl + zero extend
  191+ *  G: movzbw + cvtwX
  192+ *  H: movzwl + cvtwX
  193+ *  I: cvtld + addX
  194+ *  J: call __floatdisf
  195+ *  K: call __floatdidf
  196+ *  L: xxx + call __floatdisf
  197+ *  M: xxx + call __floatdidf
  198+ *  N: call __fixsfdi
  199+ *  O: call __fixunssfdi
  200+ *  P: call __fixdfdi
  201+ *  Q: call __fixunsdfdi
  202+ */
     
 !
<>181 -                case CHAR:
 182 -                case UCHAR:
 183 -                        printf("b");
 184 -                        return;
  204+#define MVD     1 /* mov + dest type */
  205+#define CVT     2 /* cvt + src type + dst type */
  206+#define MVZ     3 /* movz + src type + dst type */
  207+#define CSE     4 /* cvt + src type + l + sign extend upper */
  208+#define MZE     5 /* movz + src type + l + zero extend upper */
  209+#define MLE     6 /* movl + sign extend upper */
  210+#define MLZ     7 /* movl + zero extend upper */
  211+#define MZC     8 /* movz + cvt */
     
 !
<>186 -                default:
 187 -                        if ( !ISPTR( n->n_type ) ) cerror("zzzcode- bad type");
 188 -                        else {
 189 -                                printf("l");
 190 -                                return;
 191 -                                }
 192 -                }
  213+static char scary[][10] = {
  214+        { MVD, MVD, CVT, CVT, CVT, CVT, CSE, CSE, CVT, CVT },
  215+        { MVD, MVD, MVZ, MVZ, MVZ, MVZ, MZE, MZE, MZC, MZC },
  216+        { MVD, MVD, MVD, MVD, CVT, CVT, CSE, CSE, CVT, CVT },
  217+        { MVD, MVD, MVD, MVD, MVZ, MVZ, MZE, MZE, MZC, MZC },
  218+        { MVD, MVD, MVD, MVD, MVD, MVD, MLE, MLE, CVT, CVT },
  219+        { MVD, MVD, MVD, MVD, MVZ, MVZ, MLZ, MLZ, 'I', 'I' },
  220+        { MVD, MVD, MVD, MVD, MVD, MVD, MVD, MVD, 'J', 'K' },
  221+        { MVD, MVD, MVD, MVD, MVD, MVD, MVD, MVD, 'L', 'M' },
  222+        { CVT, CVT, CVT, CVT, CVT, CVT, 'N', 'O', MVD, CVT },
  223+        { CVT, CVT, CVT, CVT, CVT, CVT, 'P', 'Q', CVT, MVD },
  224+};
  225+
  226+static void
  227+sconv(NODE *p)
  228+{
  229+        NODE *l = p->n_left;
  230+        TWORD ts, td;
  231+        int o;
  232+
  233+        /*
  234+         * Source node may be in register or memory.
  235+         * Result is always in register.
  236+         */
  237+        ts = l->n_type;
  238+        if (ISPTR(ts))
  239+                ts = UNSIGNED;
  240+        td = p->n_type;
  241+        ts = ts < LONG ? ts-2 : ts-4;
  242+        td = td < LONG ? td-2 : td-4;
  243+
  244+        o = scary[ts][td];
  245+        switch (o) {
  246+        case MLE:
  247+        case MLZ:
  248+        case MVD:
  249+                expand(p, INAREG|INBREG, "\tmovZL AL,A1\n");
  250+                break;
  251+
  252+        case CSE:
  253+                expand(p, INAREG|INBREG, "\tcvtZLl AL,A1\n");
  254+                break;
  255+
  256+        case CVT:
  257+                expand(p, INAREG|INBREG, "\tcvtZLZR AL,A1\n");
  258+                break;
  259+
  260+        case MZE:
  261+                expand(p, INAREG|INBREG, "\tmovzZLl AL,A1\n");
  262+                break;
  263+
  264+        case MVZ:
  265+                expand(p, INAREG|INBREG, "\tmovzZLZR AL,A1\n");
  266+                break;
  267+
  268+        case MZC:
  269+                expand(p, INAREG|INBREG, "\tmovzZLl AL,A1\n");
  270+                expand(p, INAREG|INBREG, "\tcvtlZR A1,A1\n");
  271+                break;
  272+
  273+        default:
  274+                comperr("unsupported conversion %d", o);
  275+        }
  276+        switch (o) {
  277+        case MLE:
  278+        case CSE:
  279+                expand(p, INBREG, "\tashl $-31,A1,U1\n");
  280+                break;
  281+        case MLZ:
  282+        case MZE:
  283+                expand(p, INAREG|INBREG, "\tclrl U1\n");
  284+                break;
  285+        }
     
 !
<> 346+        char *ch;
     
 !
<> 475+        case 'G': /* emit conversion instructions */
  476+                sconv(p);
  477+                break;
  478+
     
 !
<> 504+        case 'O': /* print out emulated ops */
  505+                expand(p, FOREFF, "\tmovq       AR,-(%sp)\n");
  506+                expand(p, FOREFF, "\tmovq       AL,-(%sp)\n");
  507+                if (p->n_op == DIV && p->n_type == ULONGLONG) ch = "udiv";
  508+                else if (p->n_op == DIV) ch = "div";
  509+                else if (p->n_op == MOD && p->n_type == ULONGLONG) ch = "umod";
  510+                else if (p->n_op == MOD) ch = "mod";
  511+                else ch = 0, comperr("ZO");
  512+                printf("\tcalls $4,__%sdi3\n", ch);
  513+                break;
  514+
  515+
     
 !
<_792 -                        printf( "(ap)" );
  902+                        printf( "(%%ap)" );
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-08-31 08:15 +0200