Quick Search:

Mode

Context

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

Other Diffs

Ignore

Blank Lines Whitespace: Expand:

Diff

1.215
 
1.216
 
MAIN:ragge:20080210192221
 
reader.c
_>8989 static struct interpass prepole;
 9090 
 9191 void saveip(struct interpass *ip);
<>92 -void deljumps(void);
9392 void deltemp(NODE *p);
<>94 -void mkhardops(NODE *p);
 95 -void optdump(struct interpass *ip);
9693 void cvtemps(struct interpass *epil);
 9794 NODE *store(NODE *);
<>98 -void rcount(void);
 99 -void compile2(struct interpass *ip);
 100 -void compile3(struct interpass *ip);
 101 -void compile4(struct interpass *ip);
  95+static void fixxasm(struct interpass *ip);
10296 
 10397 static void gencode(NODE *p, int cookie);
<> 98+static void genxasm(NODE *p);
10499 
 105100 char *ltyp[] = { "", "LREG", "LOREG", "LTEMP" };
 106101 char *rtyp[] = { "", "RREG", "ROREG", "RTEMP" };
     
 !
134129 isuseless(NODE *n)
 135130 {
 136131         switch (n->n_op) {
<> 132+        case XASM:
137133         case FUNARG:
 138134         case UCALL:
 139135         case UFORTCALL:
 140136         case FORCE:
<>141 -/*      case INIT: */
142137         case ASSIGN:
 143138         case CALL:
 144139         case FORTCALL:
     
 !
245240                 }
 246241         }
 247242 
<> 243+        fixxasm(&ipole); /* setup for extended asm */
  244+
248245         optimize(&ipole);
 249246         ngenregs(&ipole);
 250247 
     
 !
290287                 case FORCE:
 291288                         gencode(p->n_left, INREGS);
 292289                         break;
<> 290+                case XASM:
  291+                        genxasm(p);
  292+                        break;
293293                 default:
 294294                         if (p->n_op != REG || p->n_type != VOID) /* XXX */
 295295                                 gencode(p, FOREFF); /* Emit instructions */
     
 !
312312                 printf("\t%s\n", ip->ip_asm);
 313313                 break;
 314314         default:
<>315 -                cerror("compile4 %d", ip->type);
  315+                cerror("emit %d", ip->type);
316316         }
 317317 }
 318318 
     
 !
476476                 p->n_su = 0; /* su calculations traverse left */
 477477                 break;
 478478 
<> 479+        case XASM:
  480+                for (p1 = p->n_left; p1->n_op == CM; p1 = p1->n_left)
  481+                        geninsn(p1->n_right, FOREFF);
  482+                geninsn(p1, FOREFF);
  483+                break;  /* all stuff already done? */
  484+
  485+        case XARG:
  486+                /* generate code for correct class here */
  487+                geninsn(p->n_left, 1 << p->n_label);
  488+                break;
  489+
479490         default:
 480491                 comperr("geninsn: bad op %s, node %p", opst[o], p);
 481492         }
     
 !
576587         p->n_rval = DECRA(p->n_reg, 0);
 577588 }
 578589 
<> 590+/*
  591+ * printout extended assembler.
  592+ */
579593 void
<> 594+genxasm(NODE *p)
  595+{
  596+        NODE *q, **nary;
  597+        int n = 1, o = 0;
  598+        char *w;
  599+
  600+        for (q = p->n_left; q->n_op == CM; q = q->n_left)
  601+                n++;
  602+        nary = tmpalloc(sizeof(NODE *)*n);
  603+        o = n;
  604+        for (q = p->n_left; q->n_op == CM; q = q->n_left) {
  605+                gencode(q->n_right->n_left, INREGS);
  606+                nary[--o] = q->n_right;
  607+        }
  608+        gencode(q->n_left, INREGS);
  609+        nary[--o] = q;
  610+
  611+        w = p->n_name;
  612+        putchar('\t');
  613+        while (*w != 0) {
  614+                if (*w == '%') {
  615+                        if (w[1] < '1' || w[1] > (n + '0'))
  616+                                uerror("bad xasm arg number");
  617+                        else
  618+                                adrput(stdout, nary[(int)w[1]-'1']->n_left);
  619+                        w++;
  620+                } else
  621+                        putchar(*w);
  622+                w++;
  623+        }
  624+        putchar('\n');
  625+}
  626+
  627+void
580628 gencode(NODE *p, int cookie)
 581629 {
 582630         struct optab *q = &table[TBLIDX(p->n_su)];
     
 !
736784                 fprintf(prfil, " %d", regno(p));
 737785                 break;
 738786 
<> 787+        case XASM:
  788+        case XARG:
  789+                fprintf(prfil, " '%s'", p->n_name);
  790+                break;
  791+
739792         case ICON:
 740793         case NAME:
 741794         case OREG:
     
 !
10131066         extern char *ftitle;
 10141067         va_list ap;
 10151068 
<> 1069+        if (nerrors) {
  1070+                fprintf(stderr,
  1071+                    "cannot recover from earlier errors: goodbye!\n");
  1072+                exit(1);
  1073+        }
  1074+
10161075         va_start(ap, str);
 10171076         fprintf(stderr, "%s, line %d: compiler error: ", ftitle, thisline);
 10181077         vfprintf(stderr, str, ap);
     
 !
11261185         }
 11271186         return -1;
 11281187 }
<_ 1188+
  1189+/*
  1190+ * Ensure that a node is correct for the destination.
  1191+ */
  1192+static void
  1193+ltypify(struct interpass *ip, NODE *p)
  1194+{
  1195+        struct interpass *ip2;
  1196+        TWORD t = p->n_left->n_type;
  1197+        NODE *q, *r;
  1198+        char *w;
  1199+//      int asg = 0, and = 0;
  1200+
  1201+#ifdef notyet
  1202+        if (myxasm(ip, p))
  1203+                return/* handled by target-specific code */
  1204+#endif
  1205+        w = p->n_name;
  1206+//      if (*w == '=')
  1207+//              w++, asg = 1;
  1208+        switch (*w) {
  1209+        case 'r': /* general reg */
  1210+                /* set register class */
  1211+                p->n_label = gclass(p->n_left->n_type);
  1212+                if (optype(p->n_left->n_op) == LTYPE)
  1213+                        break;
  1214+                q = mklnode(TEMP, 0, epp->ip_tmpnum++, t);
  1215+                r = tcopy(q);
  1216+                ip2 = ipnode(mkbinode(ASSIGN, q, p->n_left, t));
  1217+                DLIST_INSERT_BEFORE(ip, ip2, qelem);
  1218+                p->n_left = r;
  1219+                break;
  1220+        default:
  1221+                uerror("unsupported xasm option string '%s'", p->n_name);
  1222+        }
  1223+                        
  1224+
  1225+//      fwalk(p, e2print, 0);
  1226+}
  1227+
  1228+/* Extended assembler hacks */
  1229+static void
  1230+fixxasm(struct interpass *ipole)
  1231+{
  1232+        struct interpass *ip;
  1233+        NODE *p;
  1234+
  1235+        DLIST_FOREACH(ip, ipole, qelem) {
  1236+                if (ip->type != IP_NODE || ip->ip_node->n_op != XASM)
  1237+                        continue;
  1238+                /* Got an assembler node */
  1239+                p = ip->ip_node->n_left;
  1240+
  1241+                /*
  1242+                 * Ensure that the arg nodes can be directly addressable
  1243+                 * We decide that everything shall be LTYPE here.
  1244+                 */
  1245+                for (; p->n_op == CM; p = p->n_left)
  1246+                        ltypify(ip, p->n_right);
  1247+                ltypify(ip, p);
  1248+                p = ip->ip_node->n_right;
  1249+                if (p->n_op != ICON || p->n_type != STRTY)
  1250+                        uerror("xasm constraints not supported");
  1251+        }
  1252+}
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-07-11 05:29 +0200