Quick Search:

Mode

Context

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

Other Diffs

Ignore

Blank Lines Whitespace: Expand:

Diff

1.3
 
1.4
 
MAIN:gmcgarry:20071116001740
 
code.c
_>4545 void
 4646 defalign(int n)
 4747 {
 4848         n /= SZCHAR;
 4949         if (n == 1)
 5050                 return;
<>51 -        printf("        .align %d\n", n);
  51+        printf("\t.align %d\n", n);
5252 }
 5353 
 5454 /*
 5555  * define the current location as the name p->sname
 5656  * never called for text segment.
 5757  */
     
 !
6161         char *c = p->sname;
 6262 
 6363 #ifdef GCC_COMPAT
 6464         c = gcc_findname(p);
 6565 #endif
 6666         if (p->sclass == EXTDEF)
<>67 -                printf("        .globl %s\n", c);
  67+                printf("\t.globl %s\n", c);
  68+#ifdef USE_GAS
  69+        printf("\t.type %s,@object\n", c);
  70+        printf("\t.size %s," CONFMT "\n", c, tsize(p->stype, p->sdf, p->ssue));
  71+#endif
6872         printf("%s:\n", c);
 6973 }
 7074 
<>71 -
7275 /*
 7376  * code for the end of a function
 7477  * deals with struct return here
 7578  */
 7679 void
 7780 efcode()
 7881 {
 7982         if (cftnsp->stype != STRTY+FTN && cftnsp->stype != UNIONTY+FTN)
 8083                 return;
 8184 }
 8285 
 8386 /*
<>84 - * helper for bfcode() to put register arguments on stack.
 85 - */
 86 -static void
 87 -argmove(struct symtab *s, int regno)
 88 -{
 89 -        NODE *p, *r;
 90 -
 91 -        s->sclass = PARAM;
 92 -        s->soffset = NOOFFSET;
 93 -
 94 -        oalloc(s, &passedargoff);
 95 -
 96 -        spname = s;
 97 -        p = buildtree(NAME, NIL, NIL);
 98 -        r = bcon(0);
 99 -        r->n_op = REG;
 100 -        r->n_rval = regno;
 101 -        r->n_type = p->n_type;
 102 -        r->n_sue = p->n_sue;
 103 -        r->n_df = p->n_df;
 104 -        ecode(buildtree(ASSIGN, p, r));
 105 -}
 106 -
 107 -/*
10887  * code for the beginning of a function; a is an array of
 10988  * indices in symtab for the arguments; n is the number
 11089  */
 11190 void
<>112 -bfcode(struct symtab **a, int n)
  91+bfcode(struct symtab **sp, int cnt)
11392 {
<>114 -        int i, m;
  93+        NODE *p, *q;
  94+        int i, n;
11595 
<>116 -        /* Passed arguments start 64 bits above the framepointer. */
 117 -        passedargoff = ARGINIT;
 118 -        
11996         if (cftnsp->stype == STRTY+FTN || cftnsp->stype == UNIONTY+FTN) {
 12097                 /* Function returns struct, adjust arg offset */
<>121 -                for (i = 0; i < n; i++)
 122 -                        a[i]->soffset += SZPOINT(INT);
  98+                for (i = 0; i < cnt; i++)
  99+                        sp[i]->soffset += SZPOINT(INT);
123100         }
 124101 
<>125 -        m = n <= 4 ? n : 4;
 126 -        
 127 -        for(i = 0; i < m; i++) {
 128 -            /*
 129 -            if(a[i]->stype == LONGLONG || a[i]->stype == ULONGLONG) {
 130 -                printf("longlong\n");
 131 -                argmove(a[i], A0+i);
  102+        /* recalculate the arg offset and create TEMP moves */
  103+        for (n = A0, i = 0; i < cnt; i++) {
  104+                if (n + szty(sp[i]->stype) <= A0 + MIPS_NARGREGS) {
  105+                        if (xtemps) {
  106+                                p = tempnode(0, sp[i]->stype,
  107+                                    sp[i]->sdf, sp[i]->ssue);
  108+                                spname = sp[i];
  109+                                q = block(REG, NIL, NIL,
  110+                                    sp[i]->stype, sp[i]->sdf, sp[i]->ssue);
  111+                                q->n_rval = n;
  112+                                p = buildtree(ASSIGN, p, q);
  113+                                sp[i]->soffset = p->n_left->n_lval;
  114+                                sp[i]->sflags |= STNODE;
  115+                        } else {
  116+                                // sp[i]->soffset += ARGINIT;
  117+                                spname = sp[i];
  118+                                q = block(REG, NIL, NIL,
  119+                                    sp[i]->stype, sp[i]->sdf, sp[i]->ssue);
  120+                                q->n_rval = n;
  121+                                p = buildtree(ASSIGN, buildtree(NAME, 0, 0), q);
  122+                        }
  123+                        ecomp(p);
  124+                } else {
  125+                        // sp[i]->soffset += ARGINIT;
  126+                        if (xtemps) {
  127+                                /* put stack args in temps if optimizing */
  128+                                spname = sp[i];
  129+                                p = tempnode(0, sp[i]->stype,
  130+                                    sp[i]->sdf, sp[i]->ssue);
  131+                                p = buildtree(ASSIGN, p, buildtree(NAME, 0, 0));
  132+                                sp[i]->soffset = p->n_left->n_lval;
  133+                                sp[i]->sflags |= STNODE;
  134+                                ecomp(p);
  135+                        }
  136+               
  137+                }
  138+                n += szty(sp[i]->stype);
  139+        }
132140 
<>133 -                if(i+1 < 4) {
 134 -                    argmove(a[i], A0+i+1);
 135 -                }
 136 -                
 137 -                i++;            
 138 -                } else*/
 139 -            argmove(a[i], A0+i);
 140 -
 141 -        }
142141 }
 143142 
 144143 
 145144 /*
 146145  * by now, the automatics and register variables are allocated
 147146  */
     
 !
199198                         putchar(t);
 200199                 }
 201200         }
 202201 }
 203202 
 204203 /*
<>205 - * n integer words of zeros
 206 - */
 207 -void
 208 -zecode(int n)
 209 -{
 210 -        printf("        .zero %d\n", n * (SZINT/SZCHAR));
 211 -//      inoff += n * SZINT;
 212 -}
 213 -
 214 -/*
215204  * return the alignment of field of type t
 216205  */
 217206 int
 218207 fldal(unsigned int t)
 219208 {
 220209         uerror("illegal field type");
     
 !
247236                 r = buildtree(NE, r, bcon(p[i]->sval));
 248237                 cbranch(buildtree(NOT, r, NIL), bcon(p[i]->slab));
 249238         }
 250239         if (p[0]->slab > 0)
 251240                 branch(p[0]->slab);
 252241 }
<> 242+
  243+static void
  244+moveargs(NODE **n, int *regp)
  245+{
  246+        NODE *r = *n;
  247+        NODE *t;
  248+        int sz;
  249+        int regnum;
  250+
  251+        if (r->n_op == CM) {
  252+                moveargs(&r->n_left, regp);
  253+                n = &r->n_right;
  254+                r = r->n_right;
  255+        }
  256+
  257+        regnum = *regp;
  258+        sz = szty(r->n_type);
  259+
  260+        if (regnum + sz <= A0 + MIPS_NARGREGS) {
  261+                t = block(REG, NIL, NIL, r->n_type, r->n_df, r->n_sue);
  262+                t->n_rval = regnum;
  263+                t = buildtree(ASSIGN, t, r);
  264+        } else {
  265+                t = block(FUNARG, r, NIL, r->n_type, r->n_df, r->n_sue);
  266+        }
  267+
  268+        *n = t;
  269+        *regp += sz;
  270+}
  271+
253272 /*
 254273  * Called with a function call with arguments as argument.
 255274  * This is done early in buildtree() and only done once.
 256275  */
 257276 NODE *
 258277 funcode(NODE *p)
 259278 {
<> 279+        int regnum = A0;
  280+        moveargs(&p->n_right, &regnum);
<_260281         return p;
 261282 }
FishEye: Open Source License registered to PCC.
Atlassian FishEye, CVS analysis. (Version:1.6.3 Build:build-336 2008-11-04) - Administration - Page generated 2014-12-21 21:07 +0100