Quick Search:

Mode

Context

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

Other Diffs

Ignore

Blank Lines Whitespace: Expand:

Diff

1.7
 
1.8
 
MAIN:ragge:20090524132013
 
code.c
_>3030 
 3131 # include "pass1.h"
 3232 
<>33 -NODE *funarg(NODE *, int *);
 34 -int argreg(TWORD, int *);
  33+static int nsse, ngpr;
  34+enum { INTEGER = 1, INTMEM, SSE, SSEMEM, X87, STRREG, STRMEM };
  35+static const int argregsi[] = { RDI, RSI, RDX, RCX, R09, R08 };
3536 
 3637 int lastloc = -1;
 3738 
<> 39+static int argtyp(TWORD t, union dimfun *df, struct suedef *sue);
  40+
3841 /*
 3942  * Define everything needed to print out some data (or text).
 4043  * This means segment, alignment, visibility, etc.
     
 !
129132  * indices in symtab for the arguments; n is the number
 130133  */
 131134 void
<>132 -bfcode(struct symtab **sp, int cnt)
  135+bfcode(struct symtab **s, int cnt)
133136 {
<>134 -        extern int gotnr;
 135 -        NODE *n, *p, *q;
 136 -        int i, k;
  137+        struct symtab *sp;
  138+        NODE *p, *r;
  139+        int i, rno, typ;
137140 
 138141         if (cftnsp->stype == STRTY+FTN || cftnsp->stype == UNIONTY+FTN) {
 139142                 /* Function returns struct, adjust arg offset */
 140143                 for (i = 0; i < cnt; i++)
<>141 -                        sp[i]->soffset += SZPOINT(LONG);
  144+                        s[i]->soffset += SZPOINT(LONG);
142145         }
 143146 
<>144 -        if (kflag) {
 145 -                /* Put ebx in temporary */
 146 -                n = block(REG, NIL, NIL, INT, 0, MKSUE(INT));
 147 -                n->n_rval = RBX;
 148 -                p = tempnode(0, INT, 0, MKSUE(INT));
 149 -                gotnr = regno(p);
 150 -                ecomp(buildtree(ASSIGN, p, n));
 151 -        }
 152 -
153147         /* recalculate the arg offset and create TEMP moves */
<>154 -        for (k = 0, i = 0; i < cnt; i++) {
  148+        /* Always do this for reg, even if not optimizing, to free arg regs */
  149+        for (i = 0; i < cnt; i++) {
  150+                sp = s[i];
155151 
<>156 -                if (sp[i] == NULL)
 157 -                        continue;
  152+                if (sp == NULL)
  153+                        continue; /* XXX when happens this? */
158154 
<>159 -                if (k < 6) {
 160 -                        p = tempnode(0, sp[i]->stype, sp[i]->sdf, sp[i]->ssue);
 161 -                        q = block(REG, NIL, NIL, sp[i]->stype, sp[i]->sdf, sp[i]->ssue);
 162 -                        q->n_rval = argreg(sp[i]->stype, &k);
 163 -                        p = buildtree(ASSIGN, p, q);
 164 -                        sp[i]->soffset = regno(p->n_left);
 165 -                        sp[i]->sflags |= STNODE;
 166 -                        ecomp(p);
 167 -                } else {
 168 -                        sp[i]->soffset += SZLONG * k;
 169 -                        if (xtemps) {
 170 -                                /* put stack args in temps if optimizing */
 171 -                                p = tempnode(0, sp[i]->stype, sp[i]->sdf, sp[i]->ssue);
 172 -                                p = buildtree(ASSIGN, p, buildtree(NAME, 0, 0));
 173 -                                sp[i]->soffset = regno(p->n_left);
 174 -                                sp[i]->sflags |= STNODE;
 175 -                                ecomp(p);
 176 -                        }
  155+                switch (typ = argtyp(sp->stype, sp->sdf, sp->ssue)) {
  156+                case INTEGER:
  157+                case SSE:
  158+                        if (typ == SSE)
  159+                                rno = XMM0 + nsse++;
  160+                        else
  161+                                rno = argregsi[ngpr++];
  162+                        r = block(REG, NIL, NIL, sp->stype, sp->sdf, sp->ssue);
  163+                        regno(r) = rno;
  164+                        p = tempnode(0, sp->stype, sp->sdf, sp->ssue);
  165+                        sp->soffset = regno(p);
  166+                        sp->sflags |= STNODE;
  167+                        ecomp(buildtree(ASSIGN, p, r));
  168+                        break;
  169+                default:
  170+                        cerror("bfcode");
177171                 }
 178172         }
 179173 }
     
 !
204198 {
 205199 }
 206200 
<>207 -static const int argregsi[] = { RDI, RSI, RDX, RCX, R09, R08 };
 208 -
 209 -int
 210 -argreg(TWORD t, int *n)  
 211 -{
 212 -        switch (t) {
 213 -        case FLOAT:
 214 -        case DOUBLE:
 215 -        case LDOUBLE:
 216 -                /* return FR6 - *n - 2; */
 217 -                cerror("argreg");
 218 -                return 0;
 219 -        case LONGLONG:
 220 -        case ULONGLONG:
 221 -                /* TODO */;
 222 -        default:
 223 -                return argregsi[(*n)++];
 224 -        }
 225 -}
 226 -
227201 static NODE *
 228202 movtoreg(NODE *p, int rno)
 229203 {
     
 !
234208         return clocal(buildtree(ASSIGN, r, p));
 235209 
 236210 
<>237 -static int nsse, ngpr;
 238 -enum { INTEGER = 1, INTMEM, SSE, SSEMEM, X87, STRREG, STRMEM };
239211 
 240212 /*
 241213  * AMD64 parameter classification.
 242214  */
 243215 static int
<>244 -argtyp(NODE *p)
  216+argtyp(TWORD t, union dimfun *df, struct suedef *sue)
245217 {
<>246 -        TWORD t = p->n_type;
247218         int cl = 0;
 248219 
 249220         if (t <= ULONG) {
 250221                 cl = ngpr < 6 ? INTEGER : INTMEM;
 251222         } else if (t == FLOAT || t == DOUBLE) {
<>252 -                cl = nsse < 4 ? SSE : SSEMEM;
  223+                cl = nsse < 8 ? SSE : SSEMEM;
253224         } else if (t == LDOUBLE) {
 254225                 cl = X87; /* XXX */
 255226         } else if (t == STRTY) {
<>256 -                if (tsize(t, p->n_df, p->n_sue) > 4*SZLONG)
  227+                if (tsize(t, df, sue) > 4*SZLONG)
257228                         cl = STRMEM;
 258229                 else
 259230                         cerror("clasif");
     
 !
270241 
 271242         /* first arg may be struct return pointer */
 272243         /* XXX - check if varargs; setup al */
<>273 -        switch (typ = argtyp(p)) {
  244+        switch (typ = argtyp(p->n_type, p->n_df, p->n_sue)) {
274245         case INTEGER:
 275246         case SSE:
 276247                 q = talloc();
     
 !
304275 NODE *
 305276 funcode(NODE *p)
 306277 {
<> 278+        NODE *l, *r;
307279 
 308280         nsse = ngpr = 0;
 309281         listf(p->n_right, argput);
<> 282+
  283+        /* Always emit number of SSE regs used */
  284+        l = movtoreg(bcon(nsse), RAX);
  285+        if (p->n_right->n_op != CM) {
  286+                p->n_right = block(CM, l, p->n_right, INT, 0, MKSUE(INT));
  287+        } else {
  288+                for (r = p->n_right; r->n_left->n_op == CM; r = r->n_left)
  289+                        ;
  290+                r->n_left = block(CM, l, r->n_left, INT, 0, MKSUE(INT));
  291+        }
<_310292         return p;
 311293 }
 312294 
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-01 18:23 +0200