TypeSpec ASTunary_expression::typecheck (TypeSpec expected) { // FIXME - closures typecheck_children (expected); TypeSpec t = expr()->typespec(); if (t.is_structure()) { error ("Can't do '%s' to a %s.", opname(), type_c_str(t)); return TypeSpec (); } switch (m_op) { case Sub : case Add : if (t.is_string()) { error ("Can't do '%s' to a %s.", opname(), type_c_str(t)); return TypeSpec (); } m_typespec = t; break; case Not : m_typespec = TypeDesc::TypeInt; // ! is always an int break; case Compl : if (! t.is_int()) { error ("Operator '~' can only be done to an int"); return TypeSpec (); } m_typespec = t; break; default: error ("unknown unary operator"); } return m_typespec; }
void ASTNode::print (std::ostream &out, int indentlevel) const { indent (out, indentlevel); out << "(" << nodetypename() << " : " << " (type: " << typespec().string() << ") " << (opname() ? opname() : "") << "\n"; printchildren (out, indentlevel); indent (out, indentlevel); out << ")\n"; }
void ast_node_dump(const ast_node n) { if (!n) return; switch (n->type) { case N_2OP: printf(" (%s", opname(n->op)); ast_node_dump(n->left); ast_node_dump(n->right); printf(")"); return; case N_NUM: printf(" %ld", n->num); return; case N_VAR: printf(" %s", n->id); return; case N_COND: printf(" (if"); ast_node_dump(n->left); /* condition */ ast_node_dump(n->arg[0]); /* true case */ ast_node_dump(n->arg[1]); /* false case */ printf(")"); return; } printf("ERROR\n"); }
void IRPrinter::visitBinop(Binop *e) { *out << opname(e->op) << ' '; visit(e->left); *out << ", "; visit(e->right); }
void nbnsdumpmessage(NbnsMessage *s) { NbnsMessageQuestion *q; NbnsMessageResource *r; print("0x%.4ux %s %s (%d)", s->id, opname(s->opcode), s->response ? "response" : "request", s->opcode); if (s->broadcast) print(" B"); if (s->recursionavailable) print(" RA"); if (s->recursiondesired) print(" RD"); if (s->truncation) print(" TC"); if (s->authoritativeanswer) print(" AA"); if (s->response) print(" rcode %d", s->rcode); print("\n"); for (q = s->q; q; q = q->next) nbnsdumpmessagequestion(q); for (r = s->an; r; r = r->next) nbnsdumpmessageresource(r, "answer"); for (r = s->ns; r; r = r->next) nbnsdumpmessageresource(r, "ns"); for (r = s->ar; r; r = r->next) nbnsdumpmessageresource(r, "additional"); }
/* printtree1 - recursively print tree p */ static void printtree1(Tree p, int fd, int lev) { FILE *f = fd == 1 ? stdout : stderr; int i; static char blanks[] = " "; if (p == 0 || *printed(i = nodeid(p))) return; fprint(f, "#%d%S%S", i, blanks, i < 10 ? 2 : i < 100 ? 1 : 0, blanks, lev); fprint(f, "%s %t", opname(p->op), p->type); *printed(i) = 1; for (i = 0; i < NELEMS(p->kids); i++) if (p->kids[i]) fprint(f, " #%d", nodeid(p->kids[i])); if (p->op == FIELD && p->u.field) fprint(f, " %s %d..%d", p->u.field->name, fieldsize(p->u.field) + fieldright(p->u.field), fieldright(p->u.field)); else if (generic(p->op) == CNST) fprint(f, " %s", vtoa(p->type, p->u.v)); else if (p->u.sym) fprint(f, " %s", p->u.sym->name); if (p->node) fprint(f, " node=%p", p->node); fprint(f, "\n"); for (i = 0; i < NELEMS(p->kids); i++) printtree1(p->kids[i], fd, lev + 1); }
static void fuse_ll_process(void *data, const char *buf, size_t len, struct fuse_chan *ch) { struct fuse_ll *f = (struct fuse_ll *) data; struct fuse_in_header *in = (struct fuse_in_header *) buf; const void *inarg = buf + sizeof(struct fuse_in_header); struct fuse_req *req; /* Foxconn removed start pling 06/19/2009 */ #if 0 if (f->debug) fprintf(stderr, "unique: %llu, opcode: %s (%i), nodeid: %lu, insize: %zu\n", (unsigned long long) in->unique, opname((enum fuse_opcode) in->opcode), in->opcode, (unsigned long) in->nodeid, len); #endif /* Foxconn removed end pling 06/19/2009 */ req = (struct fuse_req *) calloc(1, sizeof(struct fuse_req)); if (req == NULL) { fprintf(stderr, "fuse: failed to allocate request\n"); return; } req->f = f; req->unique = in->unique; req->ctx.uid = in->uid; req->ctx.gid = in->gid; req->ctx.pid = in->pid; req->ch = ch; req->ctr = 1; list_init_req(req); fuse_mutex_init(&req->lock); if (!f->got_init && in->opcode != FUSE_INIT) fuse_reply_err(req, EIO); else if (f->allow_root && in->uid != f->owner && in->uid != 0 && in->opcode != FUSE_INIT && in->opcode != FUSE_READ && in->opcode != FUSE_WRITE && in->opcode != FUSE_FSYNC && in->opcode != FUSE_RELEASE && in->opcode != FUSE_READDIR && in->opcode != FUSE_FSYNCDIR && in->opcode != FUSE_RELEASEDIR) { fuse_reply_err(req, EACCES); } else if (in->opcode >= FUSE_MAXOP || !fuse_ll_ops[in->opcode].func) fuse_reply_err(req, ENOSYS); else { if (in->opcode != FUSE_INTERRUPT) { struct fuse_req *intr; pthread_mutex_lock(&f->lock); intr = check_interrupt(f, req); list_add_req(req, &f->list); pthread_mutex_unlock(&f->lock); if (intr) fuse_reply_err(intr, EAGAIN); } fuse_ll_ops[in->opcode].func(req, in->nodeid, inarg); } }
TypeSpec ASTloop_statement::typecheck (TypeSpec expected) { typecheck_list (init ()); oslcompiler->push_nesting (true); typecheck_list (cond ()); typecheck_list (iter ()); typecheck_list (stmt ()); oslcompiler->pop_nesting (true); TypeSpec c = cond()->typespec(); if (c.is_closure()) error ("Cannot use a closure as an '%s' condition", opname()); if (c.is_structure()) error ("Cannot use a struct as an '%s' condition", opname()); if (c.is_array()) error ("Cannot use an array as an '%s' condition", opname()); return m_typespec = TypeDesc (TypeDesc::NONE); }
static int getrule(Node p, int nt) { int rulenum; assert(p); rulenum = (*IR->x._rule)(p->x.state, nt); if (!rulenum) { fprint(stderr, "(%x->op=%s at %w is corrupt.)\n", p, opname(p->op), &src); assert(0); } return rulenum; }
void moduleInit() override { HHVM_ME(MCRouter, __construct); HHVM_NAMED_ME(MCRouter, get, mcr_str<mc_op_get>); HHVM_NAMED_ME(MCRouter, gets, mcr_str<mc_op_gets>); HHVM_NAMED_ME(MCRouter, add, mcr_set<mc_op_add>); HHVM_NAMED_ME(MCRouter, set, mcr_set<mc_op_set>); HHVM_NAMED_ME(MCRouter, replace, mcr_set<mc_op_replace>); HHVM_NAMED_ME(MCRouter, prepend, mcr_aprepend<mc_op_prepend>); HHVM_NAMED_ME(MCRouter, append, mcr_aprepend<mc_op_append>); HHVM_NAMED_ME(MCRouter, incr, mcr_str_delta<mc_op_incr>); HHVM_NAMED_ME(MCRouter, decr, mcr_str_delta<mc_op_decr>); HHVM_NAMED_ME(MCRouter, del, mcr_str<mc_op_delete>); HHVM_NAMED_ME(MCRouter, flushAll, mcr_int<mc_op_flushall>); HHVM_NAMED_ME(MCRouter, version, mcr_void<mc_op_version>); HHVM_ME(MCRouter, cas); Native::registerNativeDataInfo<MCRouter>(s_MCRouter.get()); HHVM_STATIC_ME(MCRouter, getOpName); HHVM_STATIC_ME(MCRouter, getResultName); std::string opname("mc_op_"); for (int i = 0; i < mc_nops; ++i) { std::string name; name = opname + mc_op_to_string((mc_op_t)i); // mcrouter defines op names as foo-bar, // but PHP wants constants like foo_bar for (int j = opname.size(); j < name.size(); ++j) { if (name[j] == '-') { name[j] = '_'; } } Native::registerClassConstant<KindOfInt64>( s_MCRouter.get(), makeStaticString(name), i); } for (int i = 0; i < mc_nres; ++i) { Native::registerClassConstant<KindOfInt64>( s_MCRouter.get(), makeStaticString(mc_res_to_string((mc_res_t)i)), i); } loadSystemlib(); }
/* {{{ dump_op */ static void dump_op(zend_op_array *op_array, zend_op *opi, int num, zend_uint base_address) { unsigned int flags, op1_type, op2_type, res_type; char *op_result = NULL; char *op_op1 = NULL; char *op_op2 = NULL; TSRMLS_FETCH(); /* EXT_STMT */ if (opi->opcode == 101) { fprintf(PVT_G(log_file_path), "\t<tr class=\"s\">"); } else { fprintf(PVT_G(log_file_path), "\t<tr>"); } fprintf(PVT_G(log_file_path), "<td>%d</td><td>%d</td><td title=\"%d\" class=\"wz\">%s</td>", num, opi->lineno, opi->opcode, opname(opi->opcode) ); if (!(opi->PVT_EXTENDED_VALUE(result) & EXT_TYPE_UNUSED)) { op_result = format_znode(&opi->result, base_address); fprintf(PVT_G(log_file_path), "<td>%s</td>", op_result ); if (op_result) { efree(op_result); } } else { fprintf(PVT_G(log_file_path), "<td></td>"); } op_op1 = format_znode(&opi->op1, base_address); fprintf(PVT_G(log_file_path), "<td>%s</td>", op_op1 ); if (op_op1) { efree(op_op1); } op_op2 = format_znode(&opi->op2, base_address); fprintf(PVT_G(log_file_path), "<td>%s</td></tr>\n", op_op2 ); if (op_op2) { efree(op_op2); } }
void dump_op(zend_op *op, int num){ static char buffer_op1[BUFFER_LEN]; static char buffer_op2[BUFFER_LEN]; static char buffer_result[BUFFER_LEN]; format_znode(&op->op1, buffer_op1); format_znode(&op->op2, buffer_op2); format_znode(&op->result, buffer_result); printf("%6d|%6d|%20s|%50s|%10s|%10s|%6s|\n", num, op->lineno, opname(op->opcode), get_handler(op), buffer_op1, buffer_op2, buffer_result ) ; }
char* getNodeText(Node p) { switch (generic(p->op)) { case LABEL: return stringf("LABEL %s", p->syms[0]->x.name); case ADDRL: if (isdigit(p->syms[0]->name[0])) return stringf("ADDRL t%s", p->syms[0]->name); else return stringf("ADDRL %s", p->syms[0]->name); case ADDRG: return stringf("ADDRG %s", p->syms[0]->x.name); case ADDRF: return stringf("ADDRF %s", p->syms[0]->name); case EQ: return stringf("BREQ %s", p->syms[0]->x.name); case NE: return stringf("BRNE %s", p->syms[0]->x.name); case LT: return stringf("BRLT %s", p->syms[0]->x.name); case GT: return stringf("BRGT %s", p->syms[0]->x.name); case LE: return stringf("BRLE %s", p->syms[0]->x.name); case GE: return stringf("BRGE %s", p->syms[0]->x.name); case CNST: if (optype(p->op) == I) return stringf("CNST %d", p->syms[0]->u.c.v.i); else if (optype(p->op) == U) return stringf("CNST %u", p->syms[0]->u.c.v.u); else return opname(p->op); default: return opname(p->op); } }
TypeSpec ASTassign_expression::typecheck (TypeSpec expected) { TypeSpec vt = var()->typecheck (); TypeSpec et = expr()->typecheck (vt); if (! var()->is_lvalue()) { error ("Can't assign via %s to something that isn't an lvalue", opname()); return TypeSpec(); } ASSERT (m_op == Assign); // all else handled by binary_op // We don't currently support assignment of whole arrays if (vt.is_array() || et.is_array()) { error ("Can't assign entire arrays"); return TypeSpec(); } // Special case: ok to assign a literal 0 to a closure to // initialize it. if (vt.is_closure() && ! et.is_closure() && (et.is_float() || et.is_int()) && expr()->nodetype() == literal_node && ((ASTliteral *)&(*expr()))->floatval() == 0.0f) { return TypeSpec(); // it's ok } // If either argument is a structure, they better both be the same // exact kind of structure. if (vt.is_structure() || et.is_structure()) { int vts = vt.structure(), ets = et.structure(); if (vts == ets) return m_typespec = vt; // Otherwise, a structure mismatch error ("Cannot assign '%s' to '%s'", type_c_str(et), type_c_str(vt)); return TypeSpec(); } // Expression must be of a type assignable to the lvalue if (! assignable (vt, et)) { error ("Cannot assign '%s' to '%s'", type_c_str(et), type_c_str(vt)); // FIXME - can we print the variable in question? return TypeSpec(); } return m_typespec = vt; }
static void dumptree(Node p) { if (p->op == VREG+P && p->syms[0]) { fprint(stderr, "VREGP(%s)", p->syms[0]->name); return; } else if (generic(p->op) == LOAD) { fprint(stderr, "LOAD("); dumptree(p->kids[0]); fprint(stderr, ")"); return; } fprint(stderr, "%s(", opname(p->op)); switch (generic(p->op)) { case CNST: case LABEL: case ADDRG: case ADDRF: case ADDRL: if (p->syms[0]) fprint(stderr, "%s", p->syms[0]->name); break; case RET: if (p->kids[0]) dumptree(p->kids[0]); break; case CVF: case CVI: case CVP: case CVU: case JUMP: case ARG: case BCOM: case NEG: case INDIR: dumptree(p->kids[0]); break; case CALL: if (optype(p->op) != B) { dumptree(p->kids[0]); break; } /* else fall thru */ case EQ: case NE: case GT: case GE: case LE: case LT: case ASGN: case BOR: case BAND: case BXOR: case RSH: case LSH: case ADD: case SUB: case DIV: case MUL: case MOD: dumptree(p->kids[0]); fprint(stderr, ", "); dumptree(p->kids[1]); break; default: assert(0); } fprint(stderr, ")"); }
void Unop::dump(QTextStream &out) { out << opname(op); expr->dump(out); }
void Binop::dump(QTextStream &out) { left->dump(out); out << ' ' << opname(op) << ' '; right->dump(out); }
void fimg2d_debug_command(struct fimg2d_bltcmd *cmd) { int i; struct fimg2d_param *p = &cmd->blt.param; struct fimg2d_image *img; struct fimg2d_rect *r; struct fimg2d_dma *c; if (WARN_ON(!cmd->ctx)) return; pr_info("\n[%s] ctx: %p seq_no(%u)\n", __func__, cmd->ctx, cmd->blt.seq_no); pr_info(" op: %s(%d)\n", opname(cmd->blt.op), cmd->blt.op); pr_info(" solid color: 0x%lx\n", p->solid_color); pr_info(" g_alpha: 0x%x\n", p->g_alpha); pr_info(" premultiplied: %d\n", p->premult); if (p->dither) pr_info(" dither: %d\n", p->dither); if (p->rotate) pr_info(" rotate: %d\n", p->rotate); if (p->repeat.mode) { pr_info(" repeat: %d, pad color: 0x%lx\n", p->repeat.mode, p->repeat.pad_color); } if (p->bluscr.mode) { pr_info(" bluescreen mode: %d, bs_color: 0x%lx " \ "bg_color: 0x%lx\n", p->bluscr.mode, p->bluscr.bs_color, p->bluscr.bg_color); } if (p->scaling.mode) { pr_info(" scaling %d, s:%d,%d d:%d,%d\n", p->scaling.mode, p->scaling.src_w, p->scaling.src_h, p->scaling.dst_w, p->scaling.dst_h); } if (p->clipping.enable) { pr_info(" clipping LT(%d,%d) RB(%d,%d) WH(%d,%d)\n", p->clipping.x1, p->clipping.y1, p->clipping.x2, p->clipping.y2, rect_w(&p->clipping), rect_h(&p->clipping)); } for (i = 0; i < MAX_IMAGES; i++) { img = &cmd->image[i]; r = &img->rect; if (!img->addr.type) continue; pr_info(" %s type: %d addr: 0x%lx\n", imagename(i), img->addr.type, img->addr.start); pr_info(" %s width: %d height: %d " \ "stride: %d order: %d format: %s(%d)\n", imagename(i), img->width, img->height, img->stride, img->order, cfname(img->fmt), img->fmt); pr_info(" %s rect LT(%d,%d) RB(%d,%d) WH(%d,%d)\n", imagename(i), r->x1, r->y1, r->x2, r->y2, rect_w(r), rect_h(r)); c = &cmd->dma[i].base; if (c->size) { pr_info(" %s dma base addr: 0x%lx " \ "size: 0x%x cached: 0x%x\n", imagename(i), c->addr, c->size, c->cached); } if (img->plane2.type) { pr_info(" %s plane2 type: %d addr: 0x%lx\n", imagename(i), img->plane2.type, img->plane2.start); } c = &cmd->dma[i].plane2; if (c->size) { pr_info(" %s dma plane2 addr: 0x%lx " \ "size: 0x%x cached: 0x%x\n", imagename(i), c->addr, c->size, c->cached); } } if (cmd->dma_all) pr_info(" dma size all: 0x%x bytes\n", cmd->dma_all); pr_info(" L1: 0x%x L2: 0x%x bytes\n", L1_CACHE_SIZE, L2_CACHE_SIZE); }
TypeSpec ASTbinary_expression::typecheck (TypeSpec expected) { typecheck_children (expected); TypeSpec l = left()->typespec(); TypeSpec r = right()->typespec(); // No binary ops work on structs or arrays if (l.is_structure() || r.is_structure() || l.is_array() || r.is_array()) { error ("Not allowed: '%s %s %s'", type_c_str(l), opname(), type_c_str(r)); return TypeSpec (); } // Special for closures -- just a few cases to worry about if (l.is_color_closure() || r.is_color_closure()) { if (m_op == Add) { if (l.is_color_closure() && r.is_color_closure()) return m_typespec = l; } if (m_op == Mul) { if (l.is_color_closure() && (r.is_color() || r.is_int_or_float())) return m_typespec = l; if (r.is_color_closure() && (l.is_color() || l.is_int_or_float())) { // N.B. Reorder so that it's always r = closure * k, // not r = k * closure. See codegen for why this helps. std::swap (m_children[0], m_children[1]); return m_typespec = r; } } // If we got this far, it's an op that's not allowed error ("Not allowed: '%s %s %s'", type_c_str(l), opname(), type_c_str(r)); return TypeSpec (); } switch (m_op) { case Sub : case Add : case Mul : case Div : // Add/Sub/Mul/Div work for any equivalent types, and // combination of int/float and other numeric types, but do not // work with strings. Add/Sub don't work with matrices, but // Mul/Div do. // FIXME -- currently, equivalent types combine to make the // left type. But maybe we should be more careful, for example // point-point -> vector, etc. if (l.is_string() || r.is_string()) break; // Dispense with strings trivially if ((m_op == Sub || m_op == Add) && (l.is_matrix() || r.is_matrix())) break; // Matrices don't combine for + and - if (equivalent (l, r) || (l.is_numeric() && r.is_int_or_float()) || (l.is_int_or_float() && r.is_numeric())) return m_typespec = higherprecision (l.simpletype(), r.simpletype()); break; case Mod : // Mod only works with ints, and return ints. if (l.is_int() && r.is_int()) return m_typespec = TypeDesc::TypeInt; break; case Equal : case NotEqual : // Any equivalent types can be compared with == and !=, also a // float or int can be compared to any other numeric type. // Result is always an int. if (equivalent (l, r) || (l.is_numeric() && r.is_int_or_float()) || (l.is_int_or_float() && r.is_numeric())) return m_typespec = TypeDesc::TypeInt; break; case Greater : case Less : case GreaterEqual : case LessEqual : // G/L comparisons only work with floats or ints, and always // return int. if (l.is_int_or_float() && r.is_int_or_float()) return m_typespec = TypeDesc::TypeInt; break; case BitAnd : case BitOr : case Xor : case ShiftLeft : case ShiftRight : // Bitwise ops only work with ints, and return ints. if (l.is_int() && r.is_int()) return m_typespec = TypeDesc::TypeInt; break; case And : case Or : // Logical ops work on any simple type (since they test for // nonzeroness), but always return int. return m_typespec = TypeDesc::TypeInt; default: error ("unknown binary operator"); } // If we got this far, it's an op that's not allowed error ("Not allowed: '%s %s %s'", type_c_str(l), opname(), type_c_str(r)); return TypeSpec (); }
void fimg2d_debug_command(struct fimg2d_bltcmd *cmd) { int i; struct fimg2d_blit *blt; struct fimg2d_image *img; struct fimg2d_param *p; struct fimg2d_rect *r; struct fimg2d_dma *c; if (WARN_ON(!cmd->ctx)) return; blt = &cmd->blt; /* Common information */ pr_info("\n[%s] ctx: %p seq_no(%u)\n", __func__, cmd->ctx, cmd->blt.seq_no); pr_info(" use fence: %d\n", blt->use_fence); pr_info(" Update layer : 0x%lx\n", cmd->src_flag); if (blt->dither) pr_info(" dither: %d\n", blt->dither); /* End of common information */ /* Source information */ for (i = 0; i < MAX_SRC; i++) { img = &cmd->image_src[i]; if (!img->addr.type) continue; p = &img->param; r = &img->rect; c = &cmd->dma_src[i].base; pr_info(" SRC[%d] op: %s(%d)\n", i, opname(img->op), img->op); pr_info(" SRC[%d] type: %d addr: 0x%lx\n", i, img->addr.type, img->addr.start); pr_info(" SRC[%d] width: %d height: %d ", i, img->width, img->height); pr_info(" SRC[%d] stride: %d order: %d format: %s(%d)\n", i, img->stride, img->order, cfname(img->fmt), img->fmt); pr_info(" SRC[%d] rect LT(%d,%d) RB(%d,%d) WH(%d,%d)\n", i, r->x1, r->y1, r->x2, r->y2, rect_w(r), rect_h(r)); pr_info(" solid color: 0x%lx\n", p->solid_color); pr_info(" g_alpha: 0x%x\n", p->g_alpha); pr_info(" premultiplied: %d\n", p->premult); if (p->rotate) pr_info(" rotate: %d\n", p->rotate); if (p->repeat.mode) { pr_info(" repeat: %d, pad color: 0x%lx\n", p->repeat.mode, p->repeat.pad_color); } if (p->scaling.mode) { pr_info(" scaling %d, s:%d,%d d:%d,%d\n", p->scaling.mode, p->scaling.src_w, p->scaling.src_h, p->scaling.dst_w, p->scaling.dst_h); } if (p->clipping.enable) { pr_info(" clipping LT(%d,%d) RB(%d,%d) WH(%d,%d)\n", p->clipping.x1, p->clipping.y1, p->clipping.x2, p->clipping.y2, rect_w(&p->clipping), rect_h(&p->clipping)); } if (c->size) { pr_info(" SRC[%d] dma base addr: %#lx size: %zd cached: %zd\n", i, c->addr, c->size, c->cached); pr_info(" SRC[%d] dma iova: %#lx, offset: %zd\n", i, (unsigned long)c->iova, c->offset); } } /* End of source information */ /* Destination information */ img = &cmd->image_dst; p = &img->param; r = &img->rect; c = &cmd->dma_dst.base; pr_info(" DST type: %d addr: 0x%lx\n", img->addr.type, img->addr.start); pr_info(" DST width: %d height: %d stride: %d order: %d format: %s(%d)\n", img->width, img->height, img->stride, img->order, cfname(img->fmt), img->fmt); pr_info(" DST rect LT(%d,%d) RB(%d,%d) WH(%d,%d)\n", r->x1, r->y1, r->x2, r->y2, rect_w(r), rect_h(r)); pr_info(" solid color: 0x%lx\n", p->solid_color); pr_info(" g_alpha: 0x%x\n", p->g_alpha); pr_info(" premultiplied: %d\n", p->premult); if (c->size) { pr_info(" DST dma base addr: %#lx size: %zd cached: %zd\n", c->addr, c->size, c->cached); pr_info(" DST dma iova: %#lx offset: %zd\n", (unsigned long)c->iova, c->offset); } /* End of destination */ if (cmd->dma_all) pr_info(" dma size all: %zd bytes\n", cmd->dma_all); }
static void dumptree(Node p) { switch (specific(p->op)) { case ASGN+B: assert(p->kids[0]); assert(p->kids[1]); assert(p->syms[0]); dumptree(p->kids[0]); dumptree(p->kids[1]); print("%s %d\n", opname(p->op), p->syms[0]->u.c.v.u); return; case RET+V: assert(!p->kids[0]); assert(!p->kids[1]); print("%s\n", opname(p->op)); return; } switch (generic(p->op)) { case CNST: case ADDRG: case ADDRF: case ADDRL: case LABEL: assert(!p->kids[0]); assert(!p->kids[1]); assert(p->syms[0] && p->syms[0]->x.name); print("%s %s\n", opname(p->op), p->syms[0]->x.name); return; case CVF: case CVI: case CVP: case CVU: assert(p->kids[0]); assert(!p->kids[1]); assert(p->syms[0]); dumptree(p->kids[0]); print("%s %d\n", opname(p->op), p->syms[0]->u.c.v.i); return; case ARG: case BCOM: case NEG: case INDIR: case JUMP: case RET: assert(p->kids[0]); assert(!p->kids[1]); dumptree(p->kids[0]); print("%s\n", opname(p->op)); return; case CALL: assert(p->kids[0]); assert(!p->kids[1]); assert(optype(p->op) != B); dumptree(p->kids[0]); print("%s\n", opname(p->op)); return; case ASGN: case BOR: case BAND: case BXOR: case RSH: case LSH: case ADD: case SUB: case DIV: case MUL: case MOD: assert(p->kids[0]); assert(p->kids[1]); dumptree(p->kids[0]); dumptree(p->kids[1]); print("%s\n", opname(p->op)); return; case EQ: case NE: case GT: case GE: case LE: case LT: assert(p->kids[0]); assert(p->kids[1]); assert(p->syms[0]); assert(p->syms[0]->x.name); dumptree(p->kids[0]); dumptree(p->kids[1]); print("%s %s\n", opname(p->op), p->syms[0]->x.name); return; } assert(0); }
void IRPrinter::visitUnop(Unop *e) { *out << opname(e->op) << ' '; visit(e->expr); }