4 new(int t, Node *l, Node *r)
13 n->lineno = l->lineno;
15 n->lineno = r->lineno;
23 new1(int o, Node *l, Node *r)
33 prtree(Node *n, char *s)
36 print(" == %s ==\n", s);
42 prtree1(Node *n, int d, int f)
54 prtree1(n->left, d, 0);
55 prtree1(n->right, d, 1);
65 print(" %ld", n->xoffset);
70 print(" %ld(R%d)", n->xoffset, n->reg);
76 print(" %ld+R%d", n->xoffset, n->reg);
78 print(" R%d", n->reg);
83 print(" \"%s\"", n->cstring);
88 print(" \"%S\"", n->rstring);
98 if(typefd[n->type->etype])
99 print(" \"%.8e\"", n->fconst);
101 print(" \"%lld\"", n->vconst);
106 print(" <%d>", n->addable);
108 print(" %T", n->type);
110 print(" (%d)", n->complex);
111 print(" %L\n", n->lineno);
113 prtree1(n->left, d, 1);
115 prtree1(n->right, d, 1);
123 t = alloc(sizeof(*t));
128 t->width = ewidth[et];
147 garbt(Type *t, long b)
153 t1->garb = simpleg(b);
169 case BVOLATILE|BCONSTNT:
170 return GCONSTNT|GVOLATILE;
185 case BAUTO|BREGISTER:
189 case BEXTERN|BREGISTER:
198 diag(Z, "illegal combination of classes %Q", b);
206 b &= ~BCLASS & ~BGARB;
212 case BCHAR|BUNSIGNED:
213 return types[TUCHAR];
218 case BSHORT|BINT|BSIGNED:
219 return types[TSHORT];
221 case BUNSIGNED|BSHORT:
222 case BUNSIGNED|BSHORT|BINT:
223 return types[TUSHORT];
238 case BLONG|BINT|BSIGNED:
241 case BUNSIGNED|BLONG:
242 case BUNSIGNED|BLONG|BINT:
243 return types[TULONG];
246 case BVLONG|BLONG|BINT:
247 case BVLONG|BLONG|BSIGNED:
248 case BVLONG|BLONG|BINT|BSIGNED:
249 return types[TVLONG];
251 case BVLONG|BLONG|BUNSIGNED:
252 case BVLONG|BLONG|BINT|BUNSIGNED:
253 return types[TUVLONG];
256 return types[TFLOAT];
261 return types[TDOUBLE];
267 diag(Z, "illegal combination of types %Q", b);
272 stcompat(Node *n, Type *t1, Type *t2, long ttab[])
286 if(b == BSTRUCT || b == BUNION)
287 if(!sametype(t1, t2))
290 if(b == BIND && i == TIND)
291 if(!sametype(t1, t2))
299 tcompat(Node *n, Type *t1, Type *t2, long ttab[])
302 if(stcompat(n, t1, t2, ttab)) {
304 diag(n, "incompatible type: \"%T\" for op \"%O\"",
307 diag(n, "incompatible types: \"%T\" and \"%T\" for op \"%O\"",
315 makedot(Node *n, Type *t, long o)
320 n1 = new(OXXX, Z, Z);
326 n->addable = n1->left->addable;
329 n->addable = n->left->addable;
330 if(n->addable == 0) {
331 n1 = new1(OCONST, Z, Z);
333 n1->type = types[TLONG];
344 n1 = new1(OCONST, Z, Z);
347 t->width = types[TIND]->width;
350 n2 = new1(OADDR, n->left, Z);
353 n1 = new1(OADD, n1, n2);
362 dotsearch(Sym *s, Type *t, Node *n, long *off)
371 for(t1 = t; t1 != T; t1 = t1->down)
381 if(s->class == CTYPEDEF || s->class == CTYPESTR)
382 for(t1 = t; t1 != T; t1 = t1->down)
383 if(t1->sym == S && typesu[t1->etype])
384 if(sametype(s->type, t1)) {
395 * look it up in unnamed substructures
397 for(t1 = t; t1 != T; t1 = t1->down)
398 if(t1->sym == S && typesu[t1->etype]){
399 rt = dotsearch(s, t1->link, n, off);
410 diag(n, "ambiguous structure element: %s", s->name);
415 dotoffset(Type *st, Type *lt, Node *n)
423 * first try matching at the top level
424 * for matching tag names
428 for(t=lt->link; t!=T; t=t->down)
439 * second try matching at the top level
442 for(t=lt->link; t!=T; t=t->down)
444 if(sametype(st, t)) {
453 * last try matching sub-levels
455 for(t=lt->link; t!=T; t=t->down)
457 if(typesu[t->etype]) {
458 o1 = dotoffset(st, t, n);
468 diag(n, "ambiguous unnamed structure element");
473 * look into tree for floating point constant expressions
476 allfloat(Node *n, int flag)
480 if(n->type->etype != TDOUBLE)
485 n->type = types[TFLOAT];
487 case OADD: /* no need to get more exotic than this */
491 if(!allfloat(n->right, flag))
494 if(!allfloat(n->left, flag))
497 n->type = types[TFLOAT];
505 constas(Node *n, Type *il, Type *ir)
514 if(l->garb & GCONSTNT) {
515 warn(n, "assignment to a constant type (%T)", il);
521 if(l->etype != TIND || r->etype != TIND)
527 if(r->garb & GCONSTNT)
528 if(!(l->garb & GCONSTNT)) {
529 warn(n, "assignment of a constant pointer type (%T)", ir);
536 typeext1(Type *st, Node *l)
538 if(st->etype == TFLOAT && allfloat(l, 0))
543 typeext(Type *st, Node *l)
552 if(st->etype == TIND && vconst(l) == 0) {
561 * if assign of struct containing unnamed sub-struct
562 * to type of sub-struct, insert the DOT.
563 * if assign of *struct containing unnamed substruct
564 * to type of *sub-struct, insert the add-offset
566 if(typesu[st->etype] && typesu[lt->etype]) {
567 o = dotoffset(st, lt, l);
569 n1 = new1(OXXX, Z, Z);
578 if(st->etype == TIND && typesu[st->link->etype])
579 if(lt->etype == TIND && typesu[lt->link->etype]) {
580 o = dotoffset(st->link, lt->link, l);
585 n1 = new1(OXXX, Z, Z);
587 n2 = new1(OCONST, Z, Z);
599 * a cast that generates no code
603 nocast(Type *t1, Type *t2)
622 * a cast that has a noop semantic
623 * (small to large, convert)
626 nilcast(Type *t1, Type *t2)
640 if(typefd[et1] && typefd[et2]) {
641 if(ewidth[et1] < ewidth[et2])
645 if(typechlp[et1] && typechlp[et2]) {
646 if(ewidth[et1] < ewidth[et2])
654 * "the usual arithmetic conversions are performed"
657 arith(Node *n, int f)
683 /* convert up to at least int */
690 if(i == TIND && j == TIND) {
691 w = n->right->type->link->width;
692 if(w < 1 || n->left->type->link == T || n->left->type->link->width < 1)
694 n->type = types[ewidth[TIND] <= ewidth[TLONG]? TLONG: TVLONG];
696 n1 = new1(OXXX, Z, Z);
700 n1 = new1(OCONST, Z, Z);
710 if(0 && ewidth[TIND] > ewidth[TLONG]){
711 n1 = new1(OXXX, Z, Z);
716 n->type = types[TLONG];
720 if(!sametype(n->type, n->left->type)) {
721 n->left = new1(OCAST, n->left, Z);
722 n->left->type = n->type;
723 if(n->type->etype == TIND) {
724 w = n->type->link->width;
727 w = n->type->link->width;
732 n1 = new1(OCONST, Z, Z);
735 n->left = new1(OMUL, n->left, n1);
736 n->left->type = n->type;
741 if(!sametype(n->type, n->right->type)) {
742 n->right = new1(OCAST, n->right, Z);
743 n->right->type = n->type;
744 if(n->type->etype == TIND) {
745 w = n->type->link->width;
748 w = n->type->link->width;
753 n1 = new1(OCONST, Z, Z);
756 n->right = new1(OMUL, n->right, n1);
757 n->right->type = n->type;
763 diag(n, "pointer addition not fully declared: %T", n->type->link);
767 * try to rewrite shift & mask
770 simplifyshift(Node *n)
773 int o, s1, s2, c1, c2;
775 if(!typechlp[n->type->etype])
790 if(n->right->op != OCONST)
792 if(n->left->op != OAND)
794 if(n->left->right->op != OCONST)
796 switch(n->left->left->op) {
809 if(n->left->left->right->op != OCONST)
812 c1 = n->right->vconst;
813 c2 = n->left->left->right->vconst;
814 c3 = n->left->right->vconst;
818 print("%.3o %ld %ld %d #%.lux\n",
819 (s1<<3)|s2, c1, c2, topbit(c3), c3);
824 case 000: /* (((e <<u c2) & c3) <<u c1) */
831 case 002: /* (((e >>s c2) & c3) <<u c1) */
832 if(topbit(c3) >= (32-c2))
834 case 001: /* (((e >>u c2) & c3) <<u c1) */
848 case 022: /* (((e >>s c2) & c3) >>s c1) */
851 case 012: /* (((e >>s c2) & c3) >>u c1) */
852 if(topbit(c3) >= (32-c2))
855 case 021: /* (((e >>u c2) & c3) >>s c1) */
856 if(topbit(c3) >= 31 && c2 <= 0)
859 case 011: /* (((e >>u c2) & c3) >>u c1) */
868 case 020: /* (((e <<u c2) & c3) >>s c1) */
871 case 010: /* (((e <<u c2) & c3) >>u c1) */
885 rewrite0: /* get rid of both shifts */
886 if(debug['<'])prtree(n, "rewrite0");
888 n->left = n->left->left;
889 n->right->vconst = c3;
891 rewrite1: /* get rid of lower shift */
892 if(debug['<'])prtree(n, "rewrite1");
893 n->left->left = n->left->left->left;
894 n->left->right->vconst = c3;
895 n->right->vconst = c1;
898 rewrite2: /* get rid of upper shift */
899 if(debug['<'])prtree(n, "rewrite2");
901 n->right->vconst = c3;
902 n->left->right->vconst = c1;
907 * replace shift/or with rotate left
914 if(!typeu[n->type->etype])
933 if(l->right->op != OCONST || r->right->op != OCONST)
935 if(vconst(l->right) + vconst(r->right) != ewidth[n->type->etype]*8)
937 if(l->left->type != n->type || r->left->type != n->type)
939 if(l->left->op != ONAME || r->left->op != ONAME || l->left->sym != r->left->sym)
1025 switch(n->type->etype)
1030 if(n->fconst > i || n->fconst < -i)
1059 return -159; /* first uninteresting constant */
1063 * return log(n) if n is a power of 2 constant
1072 m = MASK(8*sizeof(uvlong));
1073 for(i=32; i; i>>=1) {
1090 if(typefd[n->type->etype])
1093 return log2(n->vconst);
1110 * try to cast a constant down
1111 * rather than cast a variable up
1116 relcon(Node *l, Node *r)
1124 if(!nilcast(r->left->type, r->type))
1126 switch(r->type->etype) {
1133 v = convvtox(l->vconst, r->type->etype);
1138 l->type = r->left->type;
1148 diag(Z, "bad in relindex: %O", o);
1167 if(n == Z || n->op != OLIST)
1170 for(n = n->left; n != Z; n = n->left) {
1189 diag(Z, "bad in bitno");
1194 typebitor(long a, long b)
1200 if((a & b) == BLONG)
1201 c |= BVLONG; /* long long => vlong */
1203 warn(Z, "once is enough: %Q", a & b);
1208 diag(Node *n, char *fmt, ...)
1214 vseprint(buf, buf+sizeof(buf), fmt, arg);
1216 Bprint(&diagbuf, "%L %s\n", (n==Z)? nearln: n->lineno, buf);
1224 prtree(n, "diagnostic");
1228 Bprint(&diagbuf, "too many errors\n");
1234 warn(Node *n, char *fmt, ...)
1240 Bprint(&diagbuf, "warning: ");
1242 vseprint(buf, buf+sizeof(buf), fmt, arg);
1244 Bprint(&diagbuf, "%L %s\n", (n==Z)? nearln: n->lineno, buf);
1248 prtree(n, "warning");
1253 yyerror(char *fmt, ...)
1259 * hack to intercept message from yaccpar
1261 if(strcmp(fmt, "syntax error") == 0) {
1262 yyerror("syntax error, last name: %s", symb);
1266 vseprint(buf, buf+sizeof(buf), fmt, arg);
1268 Bprint(&diagbuf, "%L %s\n", lineno, buf);
1271 Bprint(&diagbuf, "too many errors\n");
1277 fatal(Node *n, char *fmt, ...)
1283 vseprint(buf, buf+sizeof(buf), fmt, arg);
1285 Bprint(&diagbuf, "%L %s\n", (n==Z)? nearln: n->lineno, buf);
1293 prtree(n, "diagnostic");
1299 ulong thash1 = 0x2edab8c9;
1300 ulong thash2 = 0x1dc74fb8;
1301 ulong thash3 = 0x1f241331;
1302 ulong thash[NALLTYPES];
1305 TXXX, 0x17527bbd, 0,
1306 TCHAR, 0x5cedd32b, 0,
1307 TUCHAR, 0x552c4454, 0,
1308 TSHORT, 0x63040b4b, 0,
1309 TUSHORT, 0x32a45878, 0,
1310 TINT, 0x4151d5bd, 0,
1311 TUINT, 0x5ae707d6, 0,
1312 TLONG, 0x5ef20f47, 0,
1313 TULONG, 0x36d8eb8f, 0,
1314 TVLONG, 0x6e5e9590, 0,
1315 TUVLONG, 0x75910105, 0,
1316 TFLOAT, 0x25fd7af1, 0,
1317 TDOUBLE, 0x7c40a1b2, 0,
1318 TIND, 0x1b832357, 0,
1319 TFUNC, 0x6babc9cb, 0,
1320 TARRAY, 0x7c50986d, 0,
1321 TVOID, 0x44112eff, 0,
1322 TSTRUCT, 0x7c2da3bf, 0,
1323 TUNION, 0x3eb25e98, 0,
1324 TENUM, 0x44b54f61, 0,
1325 TFILE, 0x19242ac3, 0,
1326 TOLD, 0x22b15988, 0,
1327 TDOT, 0x0204f6b3, 0,
1331 char* bnames[NALIGN];
1345 char* tnames[NALLTYPES];
1352 TUSHORT, 0, "USHORT",
1358 TUVLONG, 0, "UVLONG",
1360 TDOUBLE, 0, "DOUBLE",
1365 TSTRUCT, 0, "STRUCT",
1374 char* gnames[NGTYPES];
1378 GCONSTNT, 0, "CONST",
1379 GVOLATILE, 0, "VOLATILE",
1380 GVOLATILE|GCONSTNT, 0, "CONST-VOLATILE",
1384 char* qnames[NALLTYPES];
1391 TUSHORT, 0, "USHORT",
1397 TUVLONG, 0, "UVLONG",
1399 TDOUBLE, 0, "DOUBLE",
1404 TSTRUCT, 0, "STRUCT",
1409 TEXTERN, 0, "EXTERN",
1410 TSTATIC, 0, "STATIC",
1411 TTYPEDEF, 0, "TYPEDEF",
1412 TTYPESTR, 0, "TYPESTR",
1413 TREGISTER, 0, "REGISTER",
1414 TCONSTNT, 0, "CONSTNT",
1415 TVOLATILE, 0, "VOLATILE",
1416 TUNSIGNED, 0, "UNSIGNED",
1417 TSIGNED, 0, "SIGNED",
1423 char* cnames[NCTYPES];
1428 CEXTERN, 0, "EXTERN",
1430 CSTATIC, 0, "STATIC",
1432 CTYPEDEF, 0, "TYPEDEF",
1433 CTYPESTR, 0, "TYPESTR",
1441 char* onames[OEND+1];
1448 OANDAND, 0, "ANDAND",
1454 OASASHL, 0, "ASASHL",
1455 OASASHR, 0, "ASASHR",
1459 OASLDIV, 0, "ASLDIV",
1460 OASLMOD, 0, "ASLMOD",
1461 OASLMUL, 0, "ASLMUL",
1462 OASLSHR, 0, "ASLSHR",
1475 OCONTINUE, 0, "CONTINUE",
1478 ODOTDOT, 0, "DOTDOT",
1479 ODWHILE, 0, "DWHILE",
1491 OINDREG, 0, "INDREG",
1510 OPOSTDEC, 0, "POSTDEC",
1511 OPOSTINC, 0, "POSTINC",
1512 OPREDEC, 0, "PREDEC",
1513 OPREINC, 0, "PREINC",
1515 OREGISTER, 0, "REGISTER",
1516 ORETURN, 0, "RETURN",
1521 OSTRING, 0, "STRING",
1522 OLSTRING, 0, "LSTRING",
1523 OSTRUCT, 0, "STRUCT",
1525 OSWITCH, 0, "SWITCH",
1537 OREGPAIR, 0, "REGPAIR",
1543 /* OEQ, ONE, OLE, OLS, OLT, OLO, OGE, OHS, OGT, OHI */
1546 ONE, OEQ, OGT, OHI, OGE, OHS, OLT, OLO, OLE, OLS,
1550 OEQ, ONE, OGE, OHS, OGT, OHI, OLE, OLS, OLT, OLO,
1554 OEQ, ONE, OLS, OLS, OLO, OLO, OHS, OHS, OHI, OHI,
1560 TCHAR, TUCHAR, TSHORT, TUSHORT, TINT, TUINT, TLONG, TULONG, TVLONG, TUVLONG, -1,
1565 TUCHAR, TUSHORT, TUINT, TULONG, TUVLONG, TIND, -1,
1568 char typesuv[NTYPE];
1571 TVLONG, TUVLONG, TSTRUCT, TUNION, -1,
1574 char typeilp[NTYPE];
1577 TINT, TUINT, TLONG, TULONG, TIND, -1
1580 char typechl[NTYPE];
1581 char typechlv[NTYPE];
1582 char typechlvp[NTYPE];
1585 TCHAR, TUCHAR, TSHORT, TUSHORT, TINT, TUINT, TLONG, TULONG, -1,
1588 char typechlp[NTYPE];
1589 int typechlpinit[] =
1591 TCHAR, TUCHAR, TSHORT, TUSHORT, TINT, TUINT, TLONG, TULONG, TIND, -1,
1594 char typechlpfd[NTYPE];
1595 int typechlpfdinit[] =
1597 TCHAR, TUCHAR, TSHORT, TUSHORT, TINT, TUINT, TLONG, TULONG, TFLOAT, TDOUBLE, TIND, -1,
1609 TSHORT, TUSHORT, -1,
1615 TINT, TUINT, TLONG, TULONG, -1,
1621 TVLONG, TUVLONG, -1,
1627 TFLOAT, TDOUBLE, -1,
1639 TSTRUCT, TUNION, -1,
1648 TUSHORT, BNUMBER, 0,
1654 TUVLONG, BNUMBER, 0,
1656 TDOUBLE, BNUMBER, 0,
1658 TSTRUCT, BSTRUCT, 0,
1669 TUSHORT, BNUMBER, 0,
1675 TUVLONG, BNUMBER, 0,
1677 TDOUBLE, BNUMBER, 0,
1685 TCHAR, BNUMBER|BIND|BVOID, 0,
1686 TUCHAR, BNUMBER|BIND|BVOID, 0,
1687 TSHORT, BNUMBER|BIND|BVOID, 0,
1688 TUSHORT, BNUMBER|BIND|BVOID, 0,
1689 TINT, BNUMBER|BIND|BVOID, 0,
1690 TUINT, BNUMBER|BIND|BVOID, 0,
1691 TLONG, BNUMBER|BIND|BVOID, 0,
1692 TULONG, BNUMBER|BIND|BVOID, 0,
1693 TVLONG, BNUMBER|BIND|BVOID, 0,
1694 TUVLONG, BNUMBER|BIND|BVOID, 0,
1695 TFLOAT, BNUMBER|BVOID, 0,
1696 TDOUBLE, BNUMBER|BVOID, 0,
1697 TIND, BINTEGER|BIND|BVOID, 0,
1699 TSTRUCT, BSTRUCT|BVOID, 0,
1700 TUNION, BUNION|BVOID, 0,
1707 TCHAR, BNUMBER|BIND, 0,
1708 TUCHAR, BNUMBER|BIND, 0,
1709 TSHORT, BNUMBER|BIND, 0,
1710 TUSHORT, BNUMBER|BIND, 0,
1711 TINT, BNUMBER|BIND, 0,
1712 TUINT, BNUMBER|BIND, 0,
1713 TLONG, BNUMBER|BIND, 0,
1714 TULONG, BNUMBER|BIND, 0,
1715 TVLONG, BNUMBER|BIND, 0,
1716 TUVLONG, BNUMBER|BIND, 0,
1718 TDOUBLE, BNUMBER, 0,
1729 TUSHORT, BNUMBER, 0,
1735 TUVLONG, BNUMBER, 0,
1737 TDOUBLE, BNUMBER, 0,
1738 TIND, BINTEGER|BIND, 0,
1748 TUSHORT, BNUMBER, 0,
1754 TUVLONG, BNUMBER, 0,
1756 TDOUBLE, BNUMBER, 0,
1764 TUCHAR, BINTEGER, 0,
1765 TSHORT, BINTEGER, 0,
1766 TUSHORT, BINTEGER, 0,
1770 TULONG, BINTEGER, 0,
1771 TVLONG, BINTEGER, 0,
1772 TUVLONG, BINTEGER, 0,
1782 TUSHORT, BNUMBER, 0,
1788 TUVLONG, BNUMBER, 0,
1790 TDOUBLE, BNUMBER, 0,
1817 BNUMBER|BIND|BSTRUCT|BUNION,
1820 char tab[NTYPE][NTYPE] =
1825 /*TCHAR*/ { 0, TCHAR, TUCHAR, TSHORT, TUSHORT, TINT, TUINT, TLONG,
1826 TULONG, TVLONG, TUVLONG, TFLOAT, TDOUBLE, TIND,
1828 /*TUCHAR*/ { 0, TUCHAR, TUCHAR, TUSHORT, TUSHORT, TUINT, TUINT, TULONG,
1829 TULONG, TUVLONG, TUVLONG, TFLOAT, TDOUBLE, TIND,
1831 /*TSHORT*/ { 0, TSHORT, TUSHORT, TSHORT, TUSHORT, TINT, TUINT, TLONG,
1832 TULONG, TVLONG, TUVLONG, TFLOAT, TDOUBLE, TIND,
1834 /*TUSHORT*/ { 0, TUSHORT, TUSHORT, TUSHORT, TUSHORT, TUINT, TUINT, TULONG,
1835 TULONG, TUVLONG, TUVLONG, TFLOAT, TDOUBLE, TIND,
1837 /*TINT*/ { 0, TINT, TUINT, TINT, TUINT, TINT, TUINT, TLONG,
1838 TULONG, TVLONG, TUVLONG, TFLOAT, TDOUBLE, TIND,
1840 /*TUINT*/ { 0, TUINT, TUINT, TUINT, TUINT, TUINT, TUINT, TULONG,
1841 TULONG, TUVLONG, TUVLONG, TFLOAT, TDOUBLE, TIND,
1843 /*TLONG*/ { 0, TLONG, TULONG, TLONG, TULONG, TLONG, TULONG, TLONG,
1844 TULONG, TVLONG, TUVLONG, TFLOAT, TDOUBLE, TIND,
1846 /*TULONG*/ { 0, TULONG, TULONG, TULONG, TULONG, TULONG, TULONG, TULONG,
1847 TULONG, TUVLONG, TUVLONG, TFLOAT, TDOUBLE, TIND,
1849 /*TVLONG*/ { 0, TVLONG, TUVLONG, TVLONG, TUVLONG, TVLONG, TUVLONG, TVLONG,
1850 TUVLONG, TVLONG, TUVLONG, TFLOAT, TDOUBLE, TIND,
1852 /*TUVLONG*/ { 0, TUVLONG, TUVLONG, TUVLONG, TUVLONG, TUVLONG, TUVLONG, TUVLONG,
1853 TUVLONG, TUVLONG, TUVLONG, TFLOAT, TDOUBLE, TIND,
1855 /*TFLOAT*/ { 0, TFLOAT, TFLOAT, TFLOAT, TFLOAT, TFLOAT, TFLOAT, TFLOAT,
1856 TFLOAT, TFLOAT, TFLOAT, TFLOAT, TDOUBLE, TIND,
1858 /*TDOUBLE*/ { 0, TDOUBLE, TDOUBLE, TDOUBLE, TDOUBLE, TDOUBLE, TDOUBLE, TDOUBLE,
1859 TDOUBLE, TDOUBLE, TDOUBLE, TFLOAT, TDOUBLE, TIND,
1861 /*TIND*/ { 0, TIND, TIND, TIND, TIND, TIND, TIND, TIND,
1862 TIND, TIND, TIND, TIND, TIND, TIND,
1867 urk(char *name, int max, int i)
1870 fprint(2, "bad tinit: %s %d>=%d\n", name, i, max);
1881 for(p=thashinit; p->code >= 0; p++) {
1882 urk("thash", nelem(thash), p->code);
1883 thash[p->code] = p->value;
1885 for(p=bnamesinit; p->code >= 0; p++) {
1886 urk("bnames", nelem(bnames), p->code);
1887 bnames[p->code] = p->s;
1889 for(p=tnamesinit; p->code >= 0; p++) {
1890 urk("tnames", nelem(tnames), p->code);
1891 tnames[p->code] = p->s;
1893 for(p=gnamesinit; p->code >= 0; p++) {
1894 urk("gnames", nelem(gnames), p->code);
1895 gnames[p->code] = p->s;
1897 for(p=qnamesinit; p->code >= 0; p++) {
1898 urk("qnames", nelem(qnames), p->code);
1899 qnames[p->code] = p->s;
1901 for(p=cnamesinit; p->code >= 0; p++) {
1902 urk("cnames", nelem(cnames), p->code);
1903 cnames[p->code] = p->s;
1905 for(p=onamesinit; p->code >= 0; p++) {
1906 urk("onames", nelem(onames), p->code);
1907 onames[p->code] = p->s;
1909 for(ip=typeiinit; *ip>=0; ip++) {
1910 urk("typei", nelem(typei), *ip);
1913 for(ip=typeuinit; *ip>=0; ip++) {
1914 urk("typeu", nelem(typeu), *ip);
1917 for(ip=typesuvinit; *ip>=0; ip++) {
1918 urk("typesuv", nelem(typesuv), *ip);
1921 for(ip=typeilpinit; *ip>=0; ip++) {
1922 urk("typeilp", nelem(typeilp), *ip);
1925 for(ip=typechlinit; *ip>=0; ip++) {
1926 urk("typechl", nelem(typechl), *ip);
1931 for(ip=typechlpinit; *ip>=0; ip++) {
1932 urk("typechlp", nelem(typechlp), *ip);
1936 for(ip=typechlpfdinit; *ip>=0; ip++) {
1937 urk("typechlpfd", nelem(typechlpfd), *ip);
1938 typechlpfd[*ip] = 1;
1940 for(ip=typecinit; *ip>=0; ip++) {
1941 urk("typec", nelem(typec), *ip);
1944 for(ip=typehinit; *ip>=0; ip++) {
1945 urk("typeh", nelem(typeh), *ip);
1948 for(ip=typeilinit; *ip>=0; ip++) {
1949 urk("typeil", nelem(typeil), *ip);
1952 for(ip=typevinit; *ip>=0; ip++) {
1953 urk("typev", nelem(typev), *ip);
1958 for(ip=typefdinit; *ip>=0; ip++) {
1959 urk("typefd", nelem(typefd), *ip);
1962 for(ip=typeafinit; *ip>=0; ip++) {
1963 urk("typeaf", nelem(typeaf), *ip);
1966 for(ip=typesuinit; *ip >= 0; ip++) {
1967 urk("typesu", nelem(typesu), *ip);
1970 for(p=tasigninit; p->code >= 0; p++) {
1971 urk("tasign", nelem(tasign), p->code);
1972 tasign[p->code] = p->value;
1974 for(p=tasaddinit; p->code >= 0; p++) {
1975 urk("tasadd", nelem(tasadd), p->code);
1976 tasadd[p->code] = p->value;
1978 for(p=tcastinit; p->code >= 0; p++) {
1979 urk("tcast", nelem(tcast), p->code);
1980 tcast[p->code] = p->value;
1982 for(p=taddinit; p->code >= 0; p++) {
1983 urk("tadd", nelem(tadd), p->code);
1984 tadd[p->code] = p->value;
1986 for(p=tsubinit; p->code >= 0; p++) {
1987 urk("tsub", nelem(tsub), p->code);
1988 tsub[p->code] = p->value;
1990 for(p=tmulinit; p->code >= 0; p++) {
1991 urk("tmul", nelem(tmul), p->code);
1992 tmul[p->code] = p->value;
1994 for(p=tandinit; p->code >= 0; p++) {
1995 urk("tand", nelem(tand), p->code);
1996 tand[p->code] = p->value;
1998 for(p=trelinit; p->code >= 0; p++) {
1999 urk("trel", nelem(trel), p->code);
2000 trel[p->code] = p->value;
2003 /* 32-bit defaults */
2004 typeword = typechlp;
2005 typeswitch = typechl;
2006 typecmplx = typesuv;
2010 * return 1 if it is impossible to jump into the middle of n.
2013 deadhead(Node *n, int caseok)
2020 if(!deadhead(n->left, caseok))
2041 return deadhead(n->right, 1);
2057 return deadhead(n->right->left, caseok) && deadhead(n->right->right, caseok);
2069 return deadhead(c->left, 0) && deadhead(c->right, 0);
2073 mixedasop(Type *l, Type *r)
2075 return !typefd[l->etype] && typefd[r->etype];