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:gmcgarry:20071128022353
 
code.c
_>3232  * Simon Olsson (simols-1@student.ltu.se) 2005.
 3333  */
 3434 
<>35 -# include "pass1.h"
 36 -# include "manifest.h"
  35+#include <assert.h>
  36+#include "pass1.h"
3737 
<>38 -/* Offset to arguments passed to a function. */
 39 -int passedargoff;
 40 -
4138 /*
 4239  * cause the alignment to become a multiple of n
 4340  * never called for text segment.
     
 !
7269         printf("%s:\n", c);
 7370 }
 7471 
<> 72+static int rvnr;
  73+
7574 /*
 7675  * code for the end of a function
 7776  * deals with struct return here
 7877  */
 7978 void
 8079 efcode()
 8180 {
<> 81+        NODE *p, *q;
  82+        int tempnr;
  83+        int ty;
  84+
8285         if (cftnsp->stype != STRTY+FTN && cftnsp->stype != UNIONTY+FTN)
 8386                 return;
<> 87+
  88+        ty = cftnsp->stype - FTN;
  89+
  90+        q = block(REG, NIL, NIL, INCREF(ty), 0, cftnsp->ssue);
  91+        q->n_rval = V0;
  92+        p = tempnode(0, INCREF(ty), 0, cftnsp->ssue);
  93+        tempnr = p->n_lval;
  94+        p = buildtree(ASSIGN, p, q);
  95+        ecomp(p);
  96+
  97+        q = tempnode(tempnr, INCREF(ty), 0, cftnsp->ssue);
  98+        q = buildtree(UMUL, q, NIL);
  99+
  100+        p = tempnode(rvnr, INCREF(ty), 0, cftnsp->ssue);
  101+        p = buildtree(UMUL, p, NIL);
  102+
  103+        p = buildtree(ASSIGN, p, q);
  104+        ecomp(p);
  105+
  106+        q = tempnode(rvnr, INCREF(ty), 0, cftnsp->ssue);
  107+        p = block(REG, NIL, NIL, INCREF(ty), 0, cftnsp->ssue);
  108+        p->n_rval = V0;
  109+        p = buildtree(ASSIGN, p, q);
  110+        ecomp(p);
84111 }
 85112 
 86113 /*
     
 !
91118 bfcode(struct symtab **sp, int cnt)
 92119 {
 93120         NODE *p, *q;
<>94 -        int i, n;
  121+        int i, n, start = 0;
  122+        int sz, tsz;
95123 
<> 124+        /* assign hidden return structure to temporary */
96125         if (cftnsp->stype == STRTY+FTN || cftnsp->stype == UNIONTY+FTN) {
<>97 -                /* Function returns struct, adjust arg offset */
 98 -                for (i = 0; i < cnt; i++)
 99 -                        sp[i]->soffset += SZPOINT(INT);
  126+                p = tempnode(0, PTR+STRTY, 0, cftnsp->ssue);
  127+                rvnr = p->n_lval;
  128+                q = block(REG, NIL, NIL, PTR+STRTY, 0, cftnsp->ssue);
  129+                q->n_rval = A0 + start++;
  130+                p = buildtree(ASSIGN, p, q);
  131+                ecomp(p);
100132         }
 101133 
 102134         /* recalculate the arg offset and create TEMP moves */
<>103 -        for (n = 0, i = 0; i < cnt; i++) {
 104 -                int sz = szty(sp[i]->stype);
 105 -                if (n + sz <= nargregs) {
  135+        for (n = start, i = 0; i < cnt; i++) {
  136+
  137+                sz = tsize(sp[i]->stype, sp[i]->sdf, sp[i]->ssue) / SZINT;
  138+
  139+                /* A structure argument */
  140+                if (n < nargregs &&
  141+                    (sp[i]->stype == STRTY || sp[i]->stype == UNIONTY)) {
  142+                        tsz = sz > nargregs - n ? nargregs - n : sz;
  143+                        spname = sp[i];
  144+                        for (i = 0; i < tsz; i++) {
  145+                                q = block(REG, NIL, NIL, INT, 0, MKSUE(INT));
  146+                                q->n_rval = A0 + n + i;
  147+                                p = block(REG, NIL, NIL, INT, 0, MKSUE(INT));
  148+                                p->n_rval = FP;
  149+                                p = block(PLUS, p, bcon(ARGINIT/SZCHAR+(n+i)*4),
  150+                                    INT, 0, MKSUE(INT));
  151+                                p = block(UMUL, p, NIL, INT, 0, MKSUE(INT));
  152+                                p = buildtree(ASSIGN, p, q);
  153+                                ecomp(p);
  154+                        }
  155+                } else if (n + sz <= nargregs) {
106156                         if (xtemps) {
 107157                                 p = tempnode(0, sp[i]->stype,
 108158                                     sp[i]->sdf, sp[i]->ssue);
     
 !
136186                         }
 137187                
 138188                 }
<>139 -                n += szty(sp[i]->stype);
  189+                n += sz;
140190         }
 141191 
 142192 }
     
 !
161211 void
 162212 bjobcode()
 163213 {
<> 214+        printf("\t.section .mdebug.abi32\n");
  215+        printf("\t.previous\n");
  216+        printf("\t.abicalls\n");
164217 }
 165218 
 166219 /*
     
 !
227280 }
 228281 
 229282 static void
<>230 -moveargs(NODE **n, int *regp)
  283+moveargs(NODE **p, int *regp)
231284 {
<>232 -        NODE *r = *n;
 233 -        NODE *t;
 234 -        int sz;
  285+        NODE *r = *p;
  286+        NODE *t, *q;
  287+        int sz, tsz, n;
235288         int regnum;
 236289 
 237290         if (r->n_op == CM) {
 238291                 moveargs(&r->n_left, regp);
<>239 -                n = &r->n_right;
  292+                p = &r->n_right;
240293                 r = r->n_right;
 241294         }
 242295 
 243296         regnum = *regp;
<>244 -        sz = szty(r->n_type);
  297+        sz = tsize(r->n_type, r->n_df, r->n_sue) / SZINT;
245298 
<>246 -        if (regnum + sz <= A0 + nargregs) {
  299+        if (regnum <= A0 + nargregs && r->n_type == STRTY) {
  300+                /* copy structure into registers */
  301+                n = regnum - A0;
  302+                tsz = sz > nargregs - n ? nargregs - n : sz;
  303+                printf("[should copy %d words into registers]\n", tsz);
  304+
  305+                while (tsz > 0) {
  306+                        q = block(REG, NIL, NIL, INT, 0, MKSUE(INT));
  307+                        q->n_rval = regnum + tsz;
  308+                        q = buildtree(ASSIGN, q, r);
  309+                        r = block(CM, q, NIL, INT, 0, MKSUE(INT));
  310+                        tsz--;
  311+                }
  312+                t = r;
  313+
  314+        } else if (regnum + sz <= A0 + nargregs) {
247315                 t = block(REG, NIL, NIL, r->n_type, r->n_df, r->n_sue);
 248316                 switch(r->n_type) {
 249317                 case DOUBLE:
     
 !
259327                 }
 260328                 t = buildtree(ASSIGN, t, r);
 261329         } else {
<>262 -                t = block(FUNARG, r, NIL, r->n_type, r->n_df, r->n_sue);
 263 -        }
  330+                if (r->n_op == STARG)
  331+                        t = r;
  332+                else
  333+                        t = block(FUNARG, r, NIL, r->n_type, r->n_df, r->n_sue);
  334+        }
264335 
<>265 -        *n = t;
 266 -        *regp += sz;
  336+        *p = t;
  337+        *regp += sz;
267338 }
 268339 
 269340 /*
     
 !
274345 funcode(NODE *p)
 275346 {
 276347         int regnum = A0;
<> 348+        NODE *l, *r, *t, *q;
  349+        int ty;
  350+
  351+        l = p->n_left;
  352+        r = p->n_right;
  353+
  354+        ty = DECREF(l->n_type);
  355+        if (ty == STRTY+FTN || ty == UNIONTY+FTN) {
  356+                ty = DECREF(l->n_type) - FTN;
  357+                q = tempnode(0, ty, l->n_df, l->n_sue);
  358+                q = buildtree(ADDROF, q, NIL);
  359+                if (r->n_op != CM) {
  360+                        p->n_right = block(CM, q, r, INCREF(ty),
  361+                            l->n_df, l->n_sue);
  362+                } else {
  363+                        for (t = r; t->n_left->n_op == CM; t = t->n_left)
  364+                                ;
  365+                        t->n_left = block(CM, q, t->n_left, INCREF(ty),
  366+                            l->n_df, l->n_sue);
  367+                }
  368+        }
  369+
<_277370         moveargs(&p->n_right, &regnum);
 278371         return p;
 279372 }
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-11-01 02:16 +0100