#include "c.h"
#include "token.h"
Include dependency graph for enode.c:

Go to the source code of this file.
Defines | |
| #define | isvoidptr(ty) (isptr(ty) && unqual(ty->type) == voidtype) |
| #define | xx(a, b, c, d, e, f, g) e, |
| #define | yy(a, b, c, d, e, f, g) e, |
Functions | |
| Tree | addrof (Tree p) |
| Tree | addtree (int, Tree, Tree) |
| Tree | andtree (int, Tree, Tree) |
| Tree | asgn (Symbol p, Tree e) |
| Tree | asgntree (int op, Tree l, Tree r) |
| Type | assign (Type xty, Tree e) |
| Tree | bittree (int op, Tree l, Tree r) |
| Tree | call (Tree f, Type fty, Coordinate src) |
| Tree | calltree (Tree f, Type ty, Tree args, Symbol t3) |
| Tree | cmptree (int, Tree, Tree) |
| Tree | cnsttree (Type ty,...) |
| int | compatible (Type, Type) |
| Tree | condtree (Tree e, Tree l, Tree r) |
| Tree | consttree (unsigned n, Type ty) |
| Tree | eqtree (int op, Tree l, Tree r) |
| int | iscallb (Tree e) |
| int | isnullptr (Tree e) |
| Tree | multree (int, Tree, Tree) |
| Tree | shtree (int op, Tree l, Tree r) |
| Tree | subtree (int, Tree, Tree) |
| void | typeerror (int op, Tree l, Tree r) |
| Tree | vcall (Symbol func, Type ty,...) |
Variables | |
| Tree(* | optree [])(int, Tree, Tree) |
|
|
|
|
|
|
|
|
|
|
|
Definition at line 521 of file enode.c. Referenced by tracevalue(). 00528 :", 00529 0, 0 00530 }; 00531 00532 op = generic(op); 00533 for (i = 0; ops[i].op; i++) 00534 if (op == ops[i].op) 00535 break; 00536 assert(ops[i].name); 00537 if (r) 00538 error("operands of %s have illegal types `%t' and `%t'\n", 00539 ops[i].name, l->type, r->type); 00540 else 00541 error("operand of unary %s has illegal type `%t'\n", ops[i].name, 00542 l->type); 00543 } 00544 }
|
|
||||||||||||||||
|
|
|
||||||||||||||||
|
|
|
||||||||||||
|
Definition at line 558 of file enode.c. Referenced by bbcall(), dcllocal(), gencode(), retcode(), swstmt(), and tracecall(). |
|
||||||||||||||||
|
Definition at line 420 of file enode.c. Referenced by retcode(). 00424 {
00425 if (isarray(p->type))
00426 e = tree(ASGN+B, p->type, idtree(p),
00427 tree(INDIR+B, e->type, e, NULL));
00428 else {
00429 Type ty = p->type;
00430 p->type = unqual(p->type);
00431 if (isstruct(p->type) && p->type->u.sym->u.s.cfields) {
00432 p->type->u.sym->u.s.cfields = 0;
00433 e = asgntree(ASGN, idtree(p), e);
00434 p->type->u.sym->u.s.cfields = 1;
00435 } else
00436 e = asgntree(ASGN, idtree(p), e);
00437 p->type = ty;
00438 }
00439 return e;
00440 }
00441
00442 /* bittree - construct tree for l [& | ^ %] r */
00443 Tree bittree(int op, Tree l, Tree r) {
00444 Type ty = inttype;
00445
00446 if (isint(l->type) && isint(r->type)) {
00447 ty = binary(l->type, r->type);
00448 l = cast(l, ty);
00449 r = cast(r, ty);
00450 } else
00451 typeerror(op, l, r);
00452 return simplify(op, ty, l, r);
00453 }
00454
00455 /* multree - construct tree for l [* /] r */
00456 static Tree multree(int op, Tree l, Tree r) {
00457 Type ty = inttype;
00458
00459 if (isarith(l->type) && isarith(r->type)) {
00460 ty = binary(l->type, r->type);
00461 l = cast(l, ty);
00462 r = cast(r, ty);
00463 } else
00464 typeerror(op, l, r);
00465 return simplify(op, ty, l, r);
00466 }
00467
00468 /* shtree - construct tree for l [>> <<] r */
|
|
||||||||||||
|
Definition at line 382 of file enode.c. References p. Referenced by initializer(), initvalue(), and retcode(). 00387 {
00388 Tree q = p;
00389
00390 for (;;)
00391 switch (generic(q->op)) {
00392 case RIGHT:
00393 assert(q->kids[0] || q->kids[1]);
00394 q = q->kids[1] ? q->kids[1] : q->kids[0];
00395 continue;
00396 case ASGN:
00397 q = q->kids[1];
00398 continue;
00399 case COND: {
00400 Symbol t1 = q->u.sym;
00401 q->u.sym = 0;
00402 q = idtree(t1);
00403 /* fall thru */
00404 }
00405 case INDIR:
00406 if (p == q)
00407 return q->kids[0];
00408 q = q->kids[0];
00409 return tree(RIGHT, q->type, root(p), q);
00410 default:
00411 error("addressable object required\n");
00412 return value(p);
00413 }
00414 }
00415
00416 /* andtree - construct tree for l [&& ||] r */
00417 static Tree andtree(int op, Tree l, Tree r) {
00418 if (!isscalar(l->type) || !isscalar(r->type))
00419 typeerror(op, l, r);
|
|
||||||||||||||||
|
Definition at line 577 of file enode.c. Referenced by cnsttree(), listnodes(), and simplify(). |
|
||||||||||||||||
|
Definition at line 153 of file enode.c. Referenced by VM_CallCompiled(). 00159 {
00160 long n;
00161 ty = unqual(r->type);
00162 n = unqual(ty->type)->size;
00163 if (n == 0)
00164 error("unknown size for type `%t'\n", ty->type);
00165 l = cast(l, promote(l->type));
00166 if (n > 1)
00167 l = multree(MUL, cnsttree(signedptr, n), l);
00168 if (YYcheck && !isaddrop(r->op)) /* omit */
00169 return nullcall(ty, YYcheck, r, l); /* omit */
00170 return simplify(ADD, ty, l, r);
00171 }
00172
00173 else
00174 typeerror(op, l, r);
00175 return simplify(op, ty, l, r);
00176 }
00177
00178 Tree cnsttree(Type ty, ...) {
00179 Tree p = tree(mkop(CNST,ty), ty, NULL, NULL);
00180 va_list ap;
00181
00182 va_start(ap, ty);
00183 switch (ty->op) {
00184 case INT: p->u.v.i = va_arg(ap, long); break;
00185 case UNSIGNED:p->u.v.u = va_arg(ap, unsigned long)&ones(8*ty->size); break;
00186 case FLOAT: p->u.v.d = va_arg(ap, long double); break;
00187 case POINTER: p->u.v.p = va_arg(ap, void *); break;
00188 default: assert(0);
00189 }
00190 va_end(ap);
00191 return p;
00192 }
00193
00194 Tree consttree(unsigned n, Type ty) {
00195 if (isarray(ty))
00196 ty = atop(ty);
00197 else assert(isint(ty));
00198 return cnsttree(ty, (unsigned long)n);
00199 }
00200 static Tree cmptree(int op, Tree l, Tree r) {
00201 Type ty;
00202
00203 if (isarith(l->type) && isarith(r->type)) {
00204 ty = binary(l->type, r->type);
00205 l = cast(l, ty);
00206 r = cast(r, ty);
00207 } else if (compatible(l->type, r->type)) {
00208 ty = unsignedptr;
00209 l = cast(l, ty);
00210 r = cast(r, ty);
00211 } else {
00212 ty = unsignedtype;
00213 typeerror(op, l, r);
00214 }
00215 return simplify(mkop(op,ty), inttype, l, r);
00216 }
00217 static int compatible(Type ty1, Type ty2) {
00218 return isptr(ty1) && !isfunc(ty1->type)
00219 && isptr(ty2) && !isfunc(ty2->type)
00220 && eqtype(unqual(ty1->type), unqual(ty2->type), 0);
00221 }
00222 static int isnullptr(Tree e) {
00223 Type ty = unqual(e->type);
00224
00225 return generic(e->op) == CNST
00226 && (ty->op == INT && e->u.v.i == 0
00227 || ty->op == UNSIGNED && e->u.v.u == 0
00228 || isvoidptr(ty) && e->u.v.p == NULL);
00229 }
00230 Tree eqtree(int op, Tree l, Tree r) {
00231 Type xty = l->type, yty = r->type;
00232
00233 if (isptr(xty) && isnullptr(r)
|
|
||||||||||||||||||||
|
Definition at line 234 of file enode.c. References cast(), inttype, l, mkop, op, r, simplify(), Type, and unqual. Referenced by tracefinis(). 00236 {
00237 Type ty = unsignedptr;
00238 l = cast(l, ty);
00239 r = cast(r, ty);
00240 return simplify(mkop(op,ty), inttype, l, r);
00241 }
00242 if (isptr(yty) && isnullptr(l)
00243 || isptr(yty) && !isfunc(yty->type) && isvoidptr(xty))
00244 return eqtree(op, r, l);
00245 return cmptree(op, l, r);
00246 }
00247
00248 Type assign(Type xty, Tree e) {
00249 Type yty = unqual(e->type);
00250
00251 xty = unqual(xty);
00252 if (isenum(xty))
00253 xty = xty->type;
00254 if (xty->size == 0 || yty->size == 0)
00255 return NULL;
|
Here is the call graph for this function:

|
||||||||||||||||
|
Definition at line 334 of file enode.c. 00335 {
00336 Symbol t1;
00337 Type ty, xty = l->type, yty = r->type;
00338 Tree p;
00339
00340 if (isarith(xty) && isarith(yty))
00341 ty = binary(xty, yty);
00342 else if (eqtype(xty, yty, 1))
00343 ty = unqual(xty);
00344 else if (isptr(xty) && isnullptr(r))
00345 ty = xty;
00346 else if (isnullptr(l) && isptr(yty))
00347 ty = yty;
00348 else if (isptr(xty) && !isfunc(xty->type) && isvoidptr(yty)
00349 || isptr(yty) && !isfunc(yty->type) && isvoidptr(xty))
00350 ty = voidptype;
|
|
||||||||||||
|
Definition at line 312 of file enode.c. References BAND, bittree(), CNST, tree::field, fieldmask, fieldsize, value::i, inttype, isunsigned, l, LSH, n, tree::op, r, RSH, shtree(), type::size, tree::type, field::type, tree::u, and tree::v. Referenced by cmp(), funcdefn(), idtree(), listnodes(), simplify(), and swcode(). 00312 {
00313 long n = 8*l->u.field->type->size - fieldsize(l->u.field);
00314 if (n > 0 && isunsigned(l->u.field->type))
00315 r = bittree(BAND, r,
00316 cnsttree(r->type, (unsigned long)fieldmask(l->u.field)));
00317 else if (n > 0) {
00318 if (r->op == CNST+I) {
00319 n = r->u.v.i;
00320 if (n&(1<<(fieldsize(l->u.field)-1)))
00321 n |= ~0UL<<fieldsize(l->u.field);
00322 r = cnsttree(r->type, n);
00323 } else
00324 r = shtree(RSH,
00325 shtree(LSH, r, cnsttree(inttype, n)),
00326 cnsttree(inttype, n));
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 351 of file enode.c. References COND, l, r, typeerror(), and unqual. 00354 {
00355 typeerror(COND, l, r);
|
Here is the call graph for this function:

|
||||||||||||||||
|
Definition at line 469 of file enode.c. References cast(), inttype, isint, l, op, promote(), r, simplify(), Tree, tree::type, Type, and typeerror(). Referenced by tracevalue(). 00469 {
00470 Type ty = inttype;
00471
00472 if (isint(l->type) && isint(r->type)) {
00473 ty = promote(l->type);
00474 l = cast(l, ty);
00475 r = cast(r, inttype);
00476 } else
00477 typeerror(op, l, r);
00478 return simplify(op, ty, l, r);
00479 }
00480
00481 /* subtree - construct tree for l - r */
00482 static Tree subtree(int op, Tree l, Tree r) {
00483 long n;
00484 Type ty = inttype;
00485
00486 if (isarith(l->type) && isarith(r->type)) {
00487 ty = binary(l->type, r->type);
00488 l = cast(l, ty);
00489 r = cast(r, ty);
00490 } else if (isptr(l->type) && !isfunc(l->type->type) && isint(r->type)) {
00491 ty = unqual(l->type);
00492 n = unqual(ty->type)->size;
00493 if (n == 0)
00494 error("unknown size for type `%t'\n", ty->type);
00495 r = cast(r, promote(r->type));
00496 if (n > 1)
00497 r = multree(MUL, cnsttree(signedptr, n), r);
00498 if (isunsigned(r->type))
00499 r = cast(r, unsignedptr);
00500 else
00501 r = cast(r, signedptr);
00502 return simplify(SUB+P, ty, l, r);
00503 } else if (compatible(l->type, r->type)) {
00504 ty = unqual(l->type);
00505 n = unqual(ty->type)->size;
00506 if (n == 0)
00507 error("unknown size for type `%t'\n", ty->type);
00508 l = simplify(SUB+U, unsignedptr,
00509 cast(l, unsignedptr), cast(r, unsignedptr));
00510 return simplify(DIV+I, longtype,
00511 cast(l, longtype), cnsttree(longtype, n));
00512 } else
00513 typeerror(op, l, r);
00514 return simplify(op, ty, l, r);
00515 }
00516
00517 /* typeerror - issue "operands of op have illegal types `l' and `r'" */
00518 void typeerror(int op, Tree l, Tree r) {
00519 int i;
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 328 of file enode.c. Referenced by bbincr(), genconst(), initvalue(), tracecall(), and tracevalue(). 00335 {
|
|
||||||||||||||||
|
Definition at line 364 of file enode.c. Referenced by cmp(), and simplify(). 00368 {
00369 case CNST+I: return cast(e->u.v.i != 0 ? l : r, ty);
00370 case CNST+U: return cast(e->u.v.u != 0 ? l : r, ty);
00371 case CNST+P: return cast(e->u.v.p != 0 ? l : r, ty);
00372 case CNST+F: return cast(e->u.v.d != 0.0 ? l : r, ty);
00373 }
00374 if (ty != voidtype && ty->size > 0) {
00375 t1 = genident(REGISTER, unqual(ty), level);
00376 /* t1 = temporary(REGISTER, unqual(ty)); */
00377 l = asgn(t1, l);
00378 r = asgn(t1, r);
00379 } else
00380 t1 = NULL;
|
|
|
Definition at line 274 of file enode.c. References Aflag, inttype, isenum, type::type, Type, unqual, and warning(). Referenced by retcode(). 00274 {
00275 Type lty = unqual(xty->type), rty = unqual(yty->type);
00276 if (isenum(lty) && rty == inttype
00277 || isenum(rty) && lty == inttype) {
00278 if (Aflag >= 1)
00279 warning("assignment between `%t' and `%t' is compiler-dependent\n",
00280 xty, yty);
|
Here is the call graph for this function:

|
|
Definition at line 356 of file enode.c. 00358 {
00359 ty = unqual(unqual(ty)->type);
00360 if (isptr(xty) && isconst(unqual(xty)->type)
00361 || isptr(yty) && isconst(unqual(yty)->type))
00362 ty = qual(CONST, ty);
00363 if (isptr(xty) && isvolatile(unqual(xty)->type)
|
|
||||||||||||||||
|
|
|
||||||||||||||||
|
Definition at line 603 of file enode.c. Referenced by cnsttree(), and listnodes(). |
|
||||||||||||||||
|
|
|
||||||||||||||||
|
Definition at line 652 of file enode.c. Referenced by compatible(), and condtree(). |
|
||||||||||||||||
|
Definition at line 256 of file enode.c. References unqual. Referenced by bbentry(), and bbexit(). 00274 {
|
|
|
Definition at line 14 of file enode.c. Referenced by bbincr(), swcode(), and tracevalue(). |
1.3.9.1