Quick Search:

Mode

Context

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

Other Diffs

Ignore

Blank Lines Whitespace: Expand:

Diff

1.1
 
1.2
 
MAIN:gmcgarry:20071105145703
 
local.c
_>3535 
 3636 /*      this file contains code which is dependent on the target machine */
 3737 
<> 38+static int inbits, inval;
  39+
  40+static void
  41+fixupfuncargs(NODE *r, int *reg)
  42+{
  43+#ifdef PCC_DEBUG
  44+        if (xdebug)
  45+                printf("fixupfuncargs(): r=%p\n", r);
  46+#endif
  47+
  48+        if (r->n_op == CM) {
  49+                /* recurse to the bottom of the tree */
  50+                fixupfuncargs(r->n_left, reg);
  51+
  52+                if (*reg > A3) {
  53+                        r->n_right = block(FUNARG, r->n_right, NIL,
  54+                            r->n_right->n_type, r->n_right->n_df,
  55+                            r->n_right->n_sue);
  56+                        (*reg)++;
  57+                        return;
  58+                }
  59+
  60+                r->n_right = block(ASSIGN, NIL, r->n_right,
  61+                            r->n_right->n_type, r->n_right->n_df,
  62+                            r->n_right->n_sue);
  63+                r->n_right->n_left = block(REG, NIL, NIL, r->n_right->n_type, 0, MKSUE(INT));
  64+
  65+                if (r->n_right->n_type == ULONGLONG || r->n_right->n_type == LONGLONG) {
  66+                        r->n_right->n_left->n_rval = A0A1 + (*reg) - A0;
  67+                        (*reg) += 2;
  68+                } else {
  69+                        r->n_right->n_left->n_rval = (*reg);
  70+                        (*reg)++;
  71+                }
  72+
  73+        } else {
  74+                NODE *l = talloc();
  75+                *l = *r;
  76+                r->n_op = ASSIGN;
  77+                r->n_left = block(REG, NIL, NIL, l->n_type, 0, MKSUE(INT));
  78+                r->n_right = l;
  79+                if (r->n_right->n_type == ULONGLONG || r->n_right->n_type == LONGLONG) {
  80+                        r->n_left->n_rval = A0A1 + (*reg) - A0;
  81+                        (*reg) += 2;
  82+                } else {
  83+                        r->n_left->n_rval = (*reg);
  84+                        (*reg)++;
  85+                }
  86+        }
  87+}
  88+
  89+
3890 NODE *
 3991 clocal(NODE *p)
 4092 {
     
 !
60112 //fwalk(p, eprint, 0);
 61113         switch( o = p->n_op ){
 62114 
<> 115+        case CALL:
  116+
  117+                {
  118+                int reg = A0;
  119+                fixupfuncargs(p->n_right, &reg);
  120+                }
  121+
  122+#if 0
  123+                for (r = p->n_right; r->n_op == CM; r = r->n_left) {
  124+                        if (r->n_right->n_op != STARG &&
  125+                            r->n_right->n_op != FUNARG) {
  126+                                r->n_right = block(FUNARG, r->n_right, NIL,
  127+                                    r->n_right->n_type, r->n_right->n_df,
  128+                                    r->n_right->n_sue);
  129+                                }
  130+                }
  131+                if (r->n_op != STARG && r->n_op != FUNARG) {
  132+                        l = talloc();
  133+                        *l = *r;
  134+                        r->n_op = FUNARG; r->n_left = l; r->n_type = l->n_type;
  135+                }
  136+
  137+                break;
  138+#endif
  139+
63140         case NAME:
 64141                 if ((q = p->n_sp) == NULL)
 65142                         return p; /* Nothing to care about */
     
 !
260337                 /* put return value in return reg */
 261338                 p->n_op = ASSIGN;
 262339                 p->n_right = p->n_left;
<>263 -                p->n_left = block(REG, NIL, NIL, p->n_type, 0,
 264 -                                  MKSUE(INT));
 265 -                p->n_left->n_rval = RETREG;
  340+                p->n_left = block(REG, NIL, NIL, p->n_type, 0, MKSUE(INT));
  341+                p->n_left->n_rval = RETREG(p->n_type);;
266342                 break;
 267343         }
 268344 //printf("ut:\n");
     
 !
370446  * mat be associated with a label
 371447  */
 372448 void
<>373 -ninval(NODE *p)
  449+ninval(CONSZ off, int fsz, NODE *p)
374450 {
 375451         struct symtab *q;
 376452         TWORD t;
<> 453+        int i;
377454 
 378455         p = p->n_left;
 379456         t = p->n_type;
     
 !
383460         switch (t) {
 384461         case LONGLONG:
 385462         case ULONGLONG:
<>386 -                inval(p->n_lval & 0xffffffff);
 387 -                inval(p->n_lval >> 32);
  463+                i = (p->n_lval >> 32);
  464+                p->n_lval &= 0xffffffff;
  465+                p->n_type = INT;
  466+                ninval(off, 32, p);
  467+                p->n_lval = i;
  468+                ninval(off+32, 32, p);
388469                 break;
 389470         case INT:
 390471         case UNSIGNED:
     
 !
403484         }
 404485 }
 405486 
<> 487+#if 0
406488 /*
 407489  * print out an integer.
 408490  */
     
 !
430512                 break;
 431513         }
 432514 }
<> 515+#endif
433516 
 434517 /* make a name look like an external name in the local machine */
 435518 char *
     
 !
521604         printf(LABFMT ":\n", label);
 522605 }
 523606 
<>524 -static char *loctbl[] = { "text", "data", "section .rodata", "section .rodata" };
  607+static char *loctbl[] = { "text", "data", "data", "data" };
525608 
 526609 void
 527610 setloc1(int locc)
     
 !
531614         lastloc = locc;
 532615         printf("        .%s\n", loctbl[locc]);
 533616 }
<_ 617+
  618+/*
  619+ * Initialize a bitfield.
  620+ */
  621+void
  622+infld(CONSZ off, int fsz, CONSZ val)
  623+{
  624+        if (idebug)
  625+                printf("infld off %lld, fsz %d, val %lld inbits %d\n",
  626+                    off, fsz, val, inbits);
  627+        val &= (1 << fsz)-1;
  628+        while (fsz + inbits >= SZCHAR) {
  629+                inval |= (val << inbits);
  630+                printf("\t.byte %d\n", inval & 255);
  631+                fsz -= (SZCHAR - inbits);
  632+                val >>= (SZCHAR - inbits);
  633+                inval = inbits = 0;
  634+        }
  635+        if (fsz) {
  636+                inval |= (val << inbits);
  637+                inbits += fsz;
  638+        }
  639+}
  640+
  641+/*
  642+ * set fsz bits in sequence to zero.
  643+ */
  644+void
  645+zbits(OFFSZ off, int fsz)
  646+{
  647+        int m;
  648+
  649+        if (idebug)
  650+                printf("zbits off %lld, fsz %d inbits %d\n", off, fsz, inbits);
  651+        if ((m = (inbits % SZCHAR))) {
  652+                m = SZCHAR - m;
  653+                if (fsz < m) {
  654+                        inbits += fsz;
  655+                        return;
  656+                } else {
  657+                        fsz -= m;
  658+                        printf("\t.byte %d\n", inval);
  659+                        inval = inbits = 0;
  660+                }
  661+        }
  662+        if (fsz >= SZCHAR) {
  663+                printf("\t.zero %d\n", fsz/SZCHAR);
  664+                fsz -= (fsz/SZCHAR) * SZCHAR;
  665+        }
  666+        if (fsz) {
  667+                inval = 0;
  668+                inbits = fsz;
  669+        }
  670+}
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 11:34 +0100