Quick Search:

Mode

Context

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

Other Diffs

Ignore

Blank Lines Whitespace: Expand:

Diff

1.37
 
1.38
 
MAIN:ragge:20101108180808
 
code.c
_>151151 /*
 152152  * code for the end of a function
 153153  * deals with struct return here
<> 154+ * The return value is in (or pointed to by) RETREG.
154155  */
 155156 void
 156157 efcode()
     
 !
159160         extern int gotnr;
 160161         TWORD t;
 161162         NODE *p, *r, *l;
<>162 -        int o;
  163+        int typ, ssz;
163164 
 164165         gotnr = 0;      /* new number for next fun */
 165166         sp = cftnsp;
 166167         t = DECREF(sp->stype);
 167168         if (t != STRTY && t != UNIONTY)
 168169                 return;
<>169 -        if (argtyp(t, sp->sdf, sp->sap) != STRMEM)
 170 -                return;
171170 
<>172 -        /* call memcpy() to put return struct at destination */
 173 -#define  cmop(x,y) block(CM, x, y, INT, 0, MKAP(INT))
 174 -        r = tempnode(stroffset, INCREF(t), sp->sdf, sp->sap);
 175 -        l = block(REG, NIL, NIL, INCREF(t), sp->sdf, sp->sap);
 176 -        regno(l) = RAX;
 177 -        o = tsize(t, sp->sdf, sp->sap)/SZCHAR;
 178 -        r = cmop(cmop(r, l), bcon(o));
  171+        /* XXX should have one routine for this */
  172+        if ((typ = argtyp(t, sp->sdf, sp->sap)) == STRREG) {
  173+                /* Cast to long pointer and move to the registers */
  174+                /* XXX can overrun struct size */
  175+                /* XXX check carefully for SSE members */
179176 
<>180 -        blevel++; /* Remove prototype at exit of function */
 181 -        sp = lookup(addname("memcpy"), 0);
 182 -        if (sp->stype == UNDEF) {
 183 -                sp->sap = MKAP(VOID);
 184 -                p = block(NAME, NIL, NIL, VOID|FTN|(PTR<<TSHIFT), 0, sp->sap);
 185 -                p->n_sp = sp;
 186 -                defid(p, EXTERN);
 187 -                nfree(p);
 188 -        }
 189 -        blevel--;
  177+                if ((ssz = tsize(t, sp->sdf, sp->sap)) > SZLONG*2)
  178+                        cerror("efcode1");
190179 
<>191 -        p = doacall(sp, nametree(sp), r);
 192 -        ecomp(p);
 193 -        
 194 -
 195 -        /* RAX contains destination after memcpy() */
  180+                if (ssz > SZLONG) {
  181+                        p = block(REG, NIL, NIL, LONG+PTR, 0, MKAP(LONG));
  182+                        regno(p) = RAX;
  183+                        p = buildtree(UMUL, buildtree(PLUS, p, bcon(1)), NIL);
  184+                        ecomp(movtoreg(p, RDX));
  185+                }
  186+                p = block(REG, NIL, NIL, LONG+PTR, 0, MKAP(LONG));
  187+                regno(p) = RAX;
  188+                p = buildtree(UMUL, p, NIL);
  189+                ecomp(movtoreg(p, RAX));
  190+        } else if (typ == STRMEM) {
  191+                r = block(REG, NIL, NIL, INCREF(t), sp->sdf, sp->sap);
  192+                regno(r) = RAX;
  193+                r = buildtree(UMUL, r, NIL);
  194+                l = tempnode(stroffset, INCREF(t), sp->sdf, sp->sap);
  195+                l = buildtree(UMUL, l, NIL);
  196+                ecomp(buildtree(ASSIGN, l, r));
  197+                l = block(REG, NIL, NIL, LONG, 0, MKAP(LONG));
  198+                regno(l) = RAX;
  199+                r = tempnode(stroffset, LONG, 0, MKAP(LONG));
  200+                ecomp(buildtree(ASSIGN, l, r));
  201+        } else
  202+                cerror("efcode");
<_196203 }
 197204 
 198205 /*
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 09:49 +0100