Quick Search:

Mode

Context

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

Other Diffs

Ignore

Blank Lines Whitespace: Expand:

Diff

1.6
 
1.7
 
MAIN:ragge:20090524084331
 
code.c
_>100100                 printf(LABFMT ":\n", sp->soffset);
 101101 }
 102102 
<>103 -#if 0
104103 /*
<>105 - * AMD64 parameter classification.
 106 - */
 107 -classify(NODE *p)
 108 -{
 109 -        TWORD t = p->n_type;
 110 -        int cl = 0;
 111 -
 112 -        if (t <= ULONGLONG) {
 113 -                cl = INTEGER;
 114 -        } else if (t == FLOAT || t == DOUBLE) {
 115 -                cl = SSE;
 116 -        } else if (t == LDOUBLE) {
 117 -                cl = LDB;
 118 -        } else if (t == STRTY) {
 119 -                if (tsize(t, p->n_df, p->n_sue) > 4*SZLONG)
 120 -                        cl = MEM;
 121 -                else
 122 -                        cerror("clasif");
 123 -        } else
 124 -                cerror("FIXME: classify");
 125 -        return cl;
 126 -}
 127 -#endif
 128 -
 129 -/*
130104  * code for the end of a function
 131105  * deals with struct return here
 132106  */
     
 !
250224         }
 251225 }
 252226 
<>253 -NODE *
 254 -funarg(NODE *p, int *n)
  227+static NODE *
  228+movtoreg(NODE *p, int rno)
255229 {
 256230         NODE *r;
 257231 
<>258 -        if (p->n_op == CM) {
 259 -                p->n_left = funarg(p->n_left, n);
 260 -                p->n_right = funarg(p->n_right, n);
 261 -                return p;
 262 -        }
  232+        r = block(REG, NIL, NIL, p->n_type, 0, 0);
  233+        regno(r) = rno;
  234+        return clocal(buildtree(ASSIGN, r, p));
  235+
263236 
<>264 -        if (*n >= 6) {
 265 -                (*n)++;
 266 -                r = block(OREG, NIL, NIL, p->n_type|PTR, 0,
 267 -                    MKSUE(p->n_type|PTR));
 268 -                r->n_rval = RBP;
 269 -                r->n_lval = 16 + (*n - 6) * 8;
 270 -        } else {
 271 -                r = block(REG, NIL, NIL, p->n_type, 0, 0);
 272 -                r->n_lval = 0;
 273 -                r->n_rval = argreg(p->n_type, n);
  237+static int nsse, ngpr;
  238+enum { INTEGER = 1, INTMEM, SSE, SSEMEM, X87, STRREG, STRMEM };
  239+
  240+/*
  241+ * AMD64 parameter classification.
  242+ */
  243+static int
  244+argtyp(NODE *p)
  245+{
  246+        TWORD t = p->n_type;
  247+        int cl = 0;
  248+
  249+        if (t <= ULONG) {
  250+                cl = ngpr < 6 ? INTEGER : INTMEM;
  251+        } else if (t == FLOAT || t == DOUBLE) {
  252+                cl = nsse < 4 ? SSE : SSEMEM;
  253+        } else if (t == LDOUBLE) {
  254+                cl = X87; /* XXX */
  255+        } else if (t == STRTY) {
  256+                if (tsize(t, p->n_df, p->n_sue) > 4*SZLONG)
  257+                        cl = STRMEM;
  258+                else
  259+                        cerror("clasif");
  260+        } else
  261+                cerror("FIXME: classify");
  262+        return cl;
  263+}
  264+
  265+static void
  266+argput(NODE *p)
  267+{
  268+        NODE *q;
  269+        int typ, r;
  270+
  271+        /* first arg may be struct return pointer */
  272+        /* XXX - check if varargs; setup al */
  273+        switch (typ = argtyp(p)) {
  274+        case INTEGER:
  275+        case SSE:
  276+                q = talloc();
  277+                *q = *p;
  278+                if (typ == SSE)
  279+                        r = XMM0 + nsse++;
  280+                else
  281+                        r = argregsi[ngpr++];
  282+                q = movtoreg(q, r);
  283+                *p = *q;
  284+                nfree(q);
  285+                break;
  286+        case X87:
  287+                cerror("no long double yet");
  288+                break;
  289+        case STRMEM:
  290+                /* Struct moved to memory */
  291+        case STRREG:
  292+                /* Struct in registers */
  293+        default:
  294+                cerror("struct argument");
274295         }
<>275 -        p = block(ASSIGN, r, p, p->n_type, 0, 0);
 276 -        clocal(p);
  296+}
277297 
<>278 -        return p;
 279 -
280298 
 281299 /*
 282300  * Called with a function call with arguments as argument.
     
 !
286304 NODE *
 287305 funcode(NODE *p)
 288306 {
<>289 -        extern int gotnr;
 290 -        NODE *r, *l;
 291 -        int n = 0;
292307 
<>293 -        p->n_right = funarg(p->n_right, &n);
 294 -
 295 -        /* clear al at the end if varargs.  Do it always for now. */
 296 -        l = block(REG, NIL, NIL, INT, 0, MKSUE(INT));
 297 -        l->n_rval = RAX;
 298 -        l = buildtree(ASSIGN, l, bcon(0));
 299 -        if (p->n_right->n_op != CM) {
 300 -                p->n_right = block(CM, l, p->n_right, INT, 0, MKSUE(INT));
 301 -        } else {
 302 -                for (r = p->n_right; r->n_left->n_op == CM; r = r->n_left)
 303 -                        ;
 304 -                r->n_left = block(CM, l, r->n_left, INT, 0, MKSUE(INT));
 305 -        }
 306 -
 307 -        if (kflag == 0)
 308 -                return p;
 309 -        /* Create an ASSIGN node for ebx */
 310 -        l = block(REG, NIL, NIL, INT, 0, MKSUE(INT));
 311 -        l->n_rval = RBX;
 312 -        l = buildtree(ASSIGN, l, tempnode(gotnr, INT, 0, MKSUE(INT)));
 313 -        if (p->n_right->n_op != CM) {
 314 -                p->n_right = block(CM, l, p->n_right, INT, 0, MKSUE(INT));
 315 -        } else {
 316 -                for (r = p->n_right; r->n_left->n_op == CM; r = r->n_left)
 317 -                        ;
 318 -                r->n_left = block(CM, l, r->n_left, INT, 0, MKSUE(INT));
 319 -        }
  308+        nsse = ngpr = 0;
  309+        listf(p->n_right, argput);
<_320310         return p;
 321311 }
 322312 
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-09-03 06:45 +0200